Ledecky won her seventh career gold in the event but she was challenged like never before, touching the wall in a championship-record 8:05.62sec - a fingertip ahead of Australia's Lani Pallister (8:05.98) and McIntosh (8:07.29).
It was Canadian sensation McIntosh's first defeat of the championships and ended her bid to match Michael Phelps as the only swimmer ever to win five individual golds at a single world championships. The 18-year-old has already won three golds this week in Singapore.
Ledecky, 28, had too much staying power for her younger rival, with Pallister also in gold-medal contention until the final lunge for the line.
"They pushed me all the way," said Ledecky, a four-time Olympic champion in the event.
"I'm just really happy I could put that together. I just kept telling myself to trust my legs."
The race was billed as a potential changing of the guard, with McIntosh in red-hot form. She had also threatened Ledecky's world record earlier this year.
Pallister was determined to insert her name into the conversation as well, as the Australian kept pace with Ledecky and McIntosh in a fast start.
The lead changed hands several times but Ledecky, swimming between her two rivals, looked best-placed to strike for home.
In the end it was the American celebrating with her country's flag on the pool deck after an epic race.
"I think I just came into tonight trying to enjoy it as much as I can," said Ledecky. "I don't feel like I have much to lose at this point in my career.
"I just try to enjoy it every time I get to walk out in front of a crowd like this."
The US mixed 4x100 freestyle relay team took gold in Singapore in 3:18.48sec, beating Australia's previous leading time of 3:18.83 set in 2023. The "neutral athletes" team from Russia finished second in 3:19.68, with France third in 3:21.35.
The American team of Jack Alexy, Patrick Sammon, Kate Douglass and Torri Huske took control from the start and from then on their battle was against the clock.
"We all came out tonight wanting to get that win for Team USA and with the world record, we all knew in the back of our mind we had that ability," said Douglass.
"I'm really happy with how it turned out."
The US topped the medal table at the start of the day and their latest success consolidated their lead heading into the final day of the championships.
"It's great to be racing with my team-mates," said Alexy. "The world record was in the back of our minds."