An accident with seven laps to go triggered by pole-sitter Austin Dillon, driving the No. 3 — Earnhardt's father's number making its return to the Daytona 500 for the first time since 2001 — set up a final two-lap shootout to the finish.
Earnhardt got a great jump past Brad Keselowski on the restart, and had Gordon behind him protecting his bumper. But Denny Hamlin came charging through the field and Earnhardt suddenly had a challenger with one lap to go.
Then an accident farther back involving former winners Kevin Harvick and Jamie McMurray brought out the caution and the win belonged to Earnhardt.
"We could fight off battle after battle. We got a little help at the end there from Jeff to get away on the restart," Earnhardt said. "This is amazing. I can't believe this is happening. I never take this for granted, man because it doesn't happen twice, let alone once."
Hamlin, who won two other races in the buildup to Sunday was trying to become the first driver to sweep Daytona, wound up second in a Joe Gibbs Racing Toyota. He was strongest before the rain delay, but had an issue with his radio when the race resumed and had difficulty hearing his spotter.
"It was tough and disappointing because I definitely could have used my spotter there at the end," Hamlin said. "I'm trying to look up at the scoreboard, trying to figure out how many laps are left. I'm so 50-50 on whether I'm (mad) or I'm happy. I just don't know. Any other year, I probably would have been jumping up and down."
Keselowski finished third in a Team Penske Ford, and said after watching a replay he knew he had no chance to win once drivers behind him committed to their moves and Hamlin came charging alongside him.