Michelle Gulyas takes women's Modern Pentathlon gold for Hungary
France's Elodie Clouvel took the silver, after starting the final laser run with a 13-second advantage but then suffering a series of agonising misses in the target shooting.
South Korea's Seong Seung-min collected the bronze.
Gulyas finished with 1,461 points, nine more than Clouvel, whose time in hitting all the laser targets during four shooting stops in the 3,000 metre run was by far the slowest of the field.
With a sizeable crowd making plenty of noise, particularly for Clouvel, Gulyas held her nerve with a steady arm and firm gaze on a hot and bright afternoon.
"During shooting I was trying to focus only on myself," she told reporters. "So I was like, 15,000 people, who cares?
"But of course I cared about it because during running it was helping me a lot.
"Because of the crowd, I always knew where Elodie was, because depending on which side she was running on, the crowd was so, so loud there. So I didn't even have to look back."
Gulyas was the first Hungarian women's gold medallist in Modern Pentathlon since Zsuzsanna Voros in 2004, while Seong was the first Asian woman to medal.
Clouvel's silver added to the one she took in Rio de Janeiro in 2016 and she was thrilled.
"It was a hell of a challenge," she said. "This season I've really had some highs and lows -- a loss of confidence, I thought I couldn't do it any more, it was panic.
"Today I kept my head and my arm ... I'm so happy to have this medal, my second Olympic medal. It's crazy."
Horse refuses
French hopeful Marie Oteiza's chances had disappeared in the opening show jumping round when she fell and hit the bars as her horse, Babouchka de la Bride, refused a fence.
Spaniard Laura Heredia suffered three refusals on Dollar US D'Ecly and was also eliminated from the round.
Britain's reigning champion Kate French had withdrawn earlier due to sickness. Her absence opened the door for Germany's Annika Zillekens as reserve.
The equestrian round, taking place in the open air with the glorious Palace of Versailles as a backdrop, marked the last appearance of horses in the event.
Zillekens played a part in that change when she competed under her maiden name of Schleu in Tokyo in 2021 and was a favourite for gold until her horse repeatedly refused to jump.
German coach Kim Raisner then struck the horse with her fist, an incident that put the focus on equine welfare and raised questions about the involvement of animals in sport.
Zillekens had a clear round in the jumping on Sunday but failed to qualify for Sunday's final.