London: Michael Phelps got his hand on the wall just in the nick of time to scrape into the final of the men's 400 metres individual medley on Saturday.
The American, who won the gruelling event at the last two Olympics, won his morning heat but only snuck into the finals in eighth place after a desperate lunge on his final stroke.
Phelps stopped the clock at four minutes 13.33 seconds, just 0.07 ahead of Hungary's Laszlo Czech, who won the silver in Beijing four years ago, but missed the final after qualifying ninth.
Ryan Lochte, the reigning world champion and favourite to win gold, was third fastest overall in 4:12.35.
"It didn't feel so good, but that was my first race, and my first race is always the worst one," Lochte said. "It's hard, it's a tough field. But he's (Phelps) in."
Japan's Kosuke Hagino (4:10.01) qualified fastest ahead of South Africa's Chad le Clos (4:12.24).