Safina overcame a doubles match loss that lasted until 3:35 a.m. the previous night to defeat Li Na of China 7-6 (7-3), 7-5 in their semifinals match Saturday.
Dementieva survived against countrywoman Vera Zvonareva in the other semifinal 6-3, 7-6 (7-3). Dementieva won the Olympic silver medal eight years ago.
The men's bronze medal singles match was also played Saturday and it resulted in Serbian Novak Djokovic downing American James Blake 6-3, 7-6 (7-4).
Federer, playing in his third Olympics and still without a singles gold medal, teamed with Stanislas Wawrinka to give Switzerland the gold in doubles. They outlasted Simon Aspelin and Thomas Johansson of Sweden 6-3, 6-4, 6-7 (4-7), 6-3.
Safina admitted the long doubles match the night before took it out of her.
"It was not easy," she said. "I didn't sleep enough. I'm just really happy that I could put all my energy into the match and pull the match out."
Safina took advantage of 69 unforced errors by Li.
Sunday's men's singles title match will send Rafael Nadal of Spain against Fernando Gonzalez of Chile.