TOKYO — With four lengths of the pool remaining, there was little chance for Bobby Finke. It appeared swimmers all around the 21-year-old Floridian were managing their circumstances better. The question: Could Gregorio Paltrinieri, the reigning world champion from Italy swimming on the outer edges of the field, maintain the lead he had established from the first length.

The 800-meter freestyle, though, is about pace and power, not to mention about keeping calm. Here, then, was Finke, charging from fifth place with 200 meters to go, fifth place with 150 meters to go, fifth place with 100 meters to go …

Wait, how did he win gold?

“I had no idea,” he said afterward. “Honestly.”

The fifth day of swimming finals began Thursday morning with an unexpected and thrilling performance for the American team, with Finke blistering his final length of the pool to overtake three swimmers — including Paltrinieri, who had posted the fastest time in the world this year — to take a gold no one saw coming even 30 seconds earlier.

That was only the first surprise of the session. In the women’s 4x200 free relay, the Americans entered as decided underdogs to Australia. But in an absolutely riveting race, Katie Ledecky — who failed to medal for the first time in her Olympic career just two days earlier in the 200 free — anchored a resilient U.S. team with a brilliant leg.

Ledecky beat the Aussies, but the U.S. ended up with silver behind a surprising team from China. The standard, though, was exceptional. All three medal-winning teams broke the previous world record, with Chinese anchor Bingjie Li touching in 7 minutes, 40.33 seconds — four tenths of a second ahead of Ledecky, who touched 56 hundredths ahead of Australia’s Leah Neale.

“I just knew I was gonna let it go and go for it each lap of that race,” Ledecky said.

Ledecky’s leg of 1:53.76 was the fastest from any swimmer in the event, and it was enough to make sure the Americans kept alive their streak of medaling in this event every time it has been held.

Finally, the morning brought medals from Regan Smith and Hali Flickinger, who hauled in silver and bronze, respectively, in the women’s 200-meter butterfly, behind only the Olympic-record time of China’s Yufei Zhang.

Throw in Caeleb Dressel’s validating gold in the 100 free, and the stars of American swimming were out. Finke? With four lengths of the pool to swim, it sure appeared his would remain in the background — accomplished in getting here, with tales to take back to Gainesville, Fla., and tell his University of Florida teammates — but not a medal threat.

And then …

“I noticed like 10 meters off [the final wall] I was catching a little bit of ground,” Finke said. “And that’s the only motivation I needed to try and pass and get my hand on the wall.”

Let’s break this down, because it’s worth breaking down. When Finke arrived here, his best time in the 800 was 7 minutes, 47.58 seconds — and that came two summers ago. His fastest swim this year was in the 7:48 range — 11th-fastest in the world this year. Paltrinieri was faster. Australia’s Jack McLoughlin was faster. Ukraine’s Mykhailo Romanchuk was faster. So many people were faster — and they were all in this field.

“I was just trying to make it back to finals,” he said.

But somehow, somewhere, Finke found something. In the preliminary heats of the 800 here, he swam 7:42.72 — behind only Germany’s Florian Wellbrock and Romanchuk.

And then in the finals, he dropped another second.

“I had no idea I was gonna do that,” he said. “Honestly.”

That he did it — finishing in 7:41.87, the fastest time in the world this year — is astonishing. How he did it is almost unfathomable.

At the midway point of the race — which is 16 lengths of the 50-meter pool — Finke had pulled into second behind the Italian, Paltrinieri, who had set the pace from the start.

“I saw him, like, throughout the whole beginning,” Finke said, as did everyone in the pool. Paltrinieri looked like a rabbit who wasn’t going to die.

Over the next length of the pool, Finke dropped to fifth. Romanchuk was ahead of him. Wellbrock was ahead of him. Ukraine’s Serhii Frolov was also ahead of him.

But with 200 meters to go, something strange happened. Instead of tiring, instead of slowing, Finke started swimming faster. His 50-meter split to get to 200 meters remaining was 29.22 seconds. His next 50 was 29.18. His next 50 was 28.75. His next — with one lap to go — dropped to 28.59.

“I wasn’t holding anything back, honestly,” Finke said. “I kind of just tried to let loose and have fun. And when I noticed I started gaining some ground, I just got more motivated to try and pass them, so.”

In swimming, this is called “negative splitting” — gaining speed, rather than losing it, over the second half of a race. Finke did this in epic fashion. With 50 meters to go, he had passed Frolov. To get a medal, he needed to pass just one other swimmer. But to win gold? That would require something otherworldly — including overtaking Paltrinieri.

“I didn’t see him on the last wall or, like, the 50 before that,” Finke said. “So I was just thinking about him being there and just trying to get my hand on the wall.”

Finke powered off that final wall, and started smelling blood.

“Ten meters off the last wall — so, like, 40 meters left to go — I was like, ‘Oh, I’m catching up a little bit,” he said.

A little bit? By the midpoint of that last length, he was even with the leaders — and getting faster still. The last swimmer he caught was Paltrinieri, who he beat by 24 hundredths of a second.

When Finke realized it was gold, he looked stunned. That’s appropriate, because that last 50 was nothing if not stunning. He was asked afterward what time he might have dreamed of over that last length. “Probably high 27s,” meaning maybe 27.7 or 27.8 seconds.

His split: 26.39 seconds — a full 2.2 seconds faster than any of the previous 15 lengths he covered in the race, faster than any of the other 127 lengths covered by any of the eight swimmers by 47 hundredths. “I had no idea,” he said. More perspective: Two days earlier, Tom Dean of Britain won the 200 freestyle — a race a quarter of the distance that Finke covered. Dean’s final 50 of that race: 26.84 seconds, slower than Finke closed his 800.

And so an unexpected medal, in a most unexpected manner. The record books will show Bobby Finke won gold over 800 meters, and that’s a cherished memory. But those final 50, how will he — how will we — ever forget them?