Ledecky, 22, withdrew from her 1 500m title defence and 200m heat earlier in the week in Gwangju and feared an early exit from Saturday's 800m final after a return of the mystery bug that has plagued her for days.
"I got to the pool this morning to warm up and felt a little nauseous again which wasn't great," she said. "I had a brief moment of doubt there but pulled it together and made it happen today.
"Last night after watching all the fast swimming I said (to my coach) I so, so badly want to go have a good swim tomorrow. Just watching those records tumble... really fired me up," she added.
Five-time Olympic champion Ledecky was given a fright in the 800m by European champion Simona Quadarella but held off the Italian to win in 8:13.58 and capture a 15th world title.
"Each swim has its own story," she said.
"This one definitely has one that I'll be telling for a while," added Ledecky, revealing that she had spent seven hours in hospital on Tuesday after being struck by headaches and insomnia and experiencing an irregular pulse and elevated heart rate.
Ledecky, visibly emotional at the side of the pool, expressed a "sense of gratefulness" towards the family and coaches that had helped pep her up this week.
They were "just supporting me and reminding me of that toughness inside of me," she said.
Earlier this week, Ledecky related that a late-night text from Michael Phelps boosted her spirits during one sleepless night in Gwangju, South Korea.
"It's a good feeling," she said. "I went into the race tonight not knowing how it was going to go when I dove in, but just again wanted to end on the best note possible.
"I knew I just had to tough it out. It's special to be able to pull off something like that and trust that I can do it."
Ledecky lost her 400m world title to Australian teenager Ariarne Titmus last weekend in a stunning opening-day upset.
Caeleb Dressel, who scored a hat-trick of gold medals on Saturday, called Ledecky's comeback "phenomenal".
"I didn't see her for a couple of days," said the swimming pin-up. "Knowing Katie, if she says she's feeling a little under the weather it probably means something is very wrong.
"Goodness that girl is tough as nails," he told reporters. "How do you swim in the 800 after being sick for however many days? She's the world's best and she showed it tonight."