Katie Ledecky dominates in the 800-meter freestyle final. (Jonathan Newton/The Washington Post)

Eight minutes 4.79 seconds after she dived into the water Friday night, Katie Ledecky’s hand touched the wall, and then the waiting began.

One second, two seconds, three. The television cameras had to pan out to find the rest of the field in the final of the women’s 800-meter freestyle final, the closest pursuer some 20 meters back. Ledecky removed her top swim cap and her goggles, took a deep breath. It began to hit her: A fourth gold medal this week, a fifth overall, a second world record. And still the mortal portion of the race was not yet finished.

Four seconds, five seconds, six. In those precious moments, Ledecky, 19, could ponder the enormousness of this accomplishment and the journey that brought her here — a notion that would leave her in tears minutes later. Meanwhile, the stragglers in the field, one made up of the best female distance swimmers in the world, were crossing the middle of the pool.

Seven seconds, eight seconds, nine seconds, 10. In the stands at Olympic Aquatics Stadium, her family hugged and screamed and pumped their fists. But Ledecky was still alone at her end of the pool. The men’s 100-meter dash final Sunday in track and field will begin and end in the time she spent waiting.

Katie Ledecky's journey to becoming an Olympic gold medalist

Eleven seconds. And finally, here came the second-place finisher, Great Britain’s Jazz Carlin — with a time, 8:16.17, that would have been a world record as recently as eight years ago but now was 11.38 seconds behind Ledecky — then the third, Hungary’s Boglarka Kapas. Finally, Ledecky had some hands to shake, some friends to hug, some fellow humans with whom to share the moment.

Her face broke out into a wide smile, one that was hiding a well of tears.

“Just kind of the end of a four-year journey,” she said a few moments later, no longer able to hold them back. “I don’t know why I’m crying. There were nights I would go to bed and think about this day [and] how much fun I’ve had these past four years, and I’d start crying in bed. And I just wanted to make this meet count and have a lot of fun with it.”

It was the pinnacle of Ledecky’s swimming career — higher than the 2012 gold medal in London at the age of 15, higher than the gold medal hauls at the 2013 and 2015 world championships — which means it also may have been the pinnacle of any woman’s athletic career in history because none has been more dominant than her.

She will leave Brazil for Bethesda on Tuesday — and then head west to Stanford University a few weeks later — with four gold medals and a silver, the first woman to sweep the 200, 400 and 800 freestyles in 48 years, the third American woman in history to win four golds in a single Olympics. She will leave with two more world records under her ledger, making it 13 for her career, with Friday night marking the fifth time she has lowered the record in the 800 and the third time in a little more than a year. She owns the top 13 times in history at that distance.

“I felt that it was faster than any 800 I’ve ever done before,” she said when asked whether she believed she had the record, “so I was pretty sure.”

With 2,600 competitive meters already under her belt this week but with nothing left for which to hold anything back, Ledecky shot off the blocks like a sprinter, going 28.03 in her first 50, 57.98 in her first 100 and opening up a 2½ -length lead by the 200-meter wall while still barely kicking. And then came the legs, powerful and rhythmic, propelling her forward, her lead getting visibly wider by the minute. At the midway point, she was more than a second ahead of her own world record pace and some 10 meters ahead of her closest competitor.

By the last laps, the only question was how low Ledecky could go. After the 2013 world championships, where she won four gold medals and forced a recalibration of her goals with her coach, Bruce Gemmell, she emerged with two new times to shoot for three years down the road in Rio de Janeiro — a 3:56-something in the 400 free, which she nailed with a 3:56.46 on Sunday, and a sub-8:05 in the 800.

Turning at the 750-meter mark, she was a full two seconds ahead of world record pace and 20 meters clear of the field, but she still bore down on the wall. Her final 50-meter split of 28.99 was her second fastest of any lap in her individual events this week, excluding opening laps with a diving start. Only the second lap of her 200 free — a 28.43 — had been faster.

“I hit all my goals right on the nose this week, and I couldn’t be happier with how this week has gone,” she said. “I think it’s just a testament to the vision that Bruce and I had three years ago, and we weren’t going to stop until we hit those goals.”

Gemmell, her coach since the fall of 2012, couldn’t recall the last time he had a good cry himself and had never seen such emotion from Ledecky, but after the race — their last together as a day-to-day tandem — as they shared a hug, neither of them even tried to hold back the tears. When Gemmell, 55, spoke to a handful of reporters well after midnight, emotionally drained, one of them asked what that private moment with her had been like, and he needed 75 seconds, sighing multiple times, turning his back twice and walking away, cursing under his breath at his inability to stay composed, to find the voice to whisper a few halting words.

“Just four years . . . of everything,” he said, wiping his eyes. “She’s pretty special. She’s pretty special.”

Ledecky was into her fourth answer in the “mixed zone” — where reporters ask questions of athletes from behind a metal fence — and clutching a towel to her chest against the chill when the tears started again.

“The memories mean a lot more to me than the medals,” she said, beginning to choke up, “and these past three years have been incredible.”

A swimmer’s life is measured in fractions of seconds in races, in minute-long sets repeated over and over in practice, in hours spent staring at a black line at the bottom of the pool. Suddenly, Ledecky was contemplating years — the ones that have passed and the ones still to come. It was enough to leave a champion in tears.