LONDON — Larisa Latynina won 18 Olympic medals in gymnastics for the Soviet Union, but she attended swimming Tuesday night. Michael Phelps was racing. He was trying to beat everyone in the pool and Latynina’s record as well. And when the moment came, she knew exactly what a great champion should do. She put on her lipstick.

For nearly half a century, no one approached the number of Olympic medals that Latynina won from 1956 to 1964. She was the first superstar in gymnastics at a time when womanly grace prevailed over teenage acrobatics. But Phelps tied her record Tuesday with a silver medal in the 200-meter butterfly and surpassed it with gold by swimming the anchor leg of the 4x200 freestyle relay.

Latynina joked in recent weeks that it was time for a man to be able to do what a woman had done long ago. And that it was too bad Phelps was not Russian.

“Forty-eight years is almost enough time to hold a record,” Latynina, 77, said earlier Tuesday by phone.