Updated

Sam Hornish Jr. overcame a disastrous mistake in the pits and a pair of Andrettis on Sunday to win the Indianapolis 500.

Hornish lost a lap late in the race when he was penalized for leaving his pit with the fuel hose still connected. Somehow, with pit strategies playing a role, he found himself back on the lead lap and in fourth, trailing Michael Andretti, his 19-year-old son Marco and Scott Dixon with two laps to go.

A late caution flag brought out when Felipe Giaffone crashed set up one of the most dramatic finishes in Indy history.

Click here for complete Indy 500 coverage from FOXSports.com.

Hornish, the pole-starter who has been the fastest driver here virtually the entire month, charged from the moment the green flag waved with four laps to go on the 2.5-mile oval.

As Marco Andretti brought the huge crowd to its feet by passing his father for the lead on lap 198, Hornish followed, passing the elder Andretti — who made a comeback after retiring from the cockpit in 2003 to run with his son — for second.

Hornish caught Marco and tried to dive below him in the third turn on lap 199 and the two almost collided as Hornish fell several car-lengths back.

On the final lap, Hornish, who had failed to finish the 500 in his first six tries, set sail again, moving up to the rear of Andretti's Dallara. Marco, running in only his fourth IRL IndyCar Series event, did his best to block the two-time series champion, but it wasn't enough.

Hornish swung low on the final straightaway, pulled alongside and nosed ahead at the finish, a half car-length ahead at the checkered flag.

"Thank goodness it's 500 instead of 497 1/2," Hornish said.

Marco Andretti wasn't satisfied with second place.

"Man, I don't want to wait for next year," he said. "It's a bummer. Woulda, coulda, shoulda, I mean — second place is nothing."

For complete sports coverage visit FOXSports.com.