The former Everton midfielder struck three minutes into stoppage time against 10-man Algeria to send his side through as group winners ahead of second-placed England.
Donovan pounced from close range when keeper Rais Mbolhi parried a Clint Dempsey shot into his path to spark wild scenes of celebration among Bob Bradley's men at such a stunning late twist.
It was an amazing finish to a pulsating game after it looked like being another 90 minutes of heartbreak as Dempsey suffered more referee injustice in a drama-filled, action-packed clash in Pretoria.
Cheered on by former US President Bill Clinton, the unlucky striker saw his close-range follow-up ruled out for offside - even though TV replays showed he was level with the last defender in a pivotal moment just before the interval.
It was the second time in two games USA have had a good goal dubiously chalked off - midfielder Maurice Edu being denied a late winner in the 2-2 draw with Slovenia.
Dempsey also hit the woodwork after the break before blazing the rebound into orbit as the States spurned several chances before Donovan's late intervention with his 44th international goal deep into stoppage time.
It proved all too much for Algeria's Anther Yahia, who saw red for a second caution as frustrations boiled over.
Algeria had to win to keep their slim World Cup dream alive, and went straight at the States' shaky-looking defence right from the start. They were almost ahead inside the first 10 minutes when recalled striker Rafik Djebbour pounced on a mistake from Watford's Jay DeMerit inside the box before firing a 12-yard effort against the bar with keeper Tim Howard beaten.
Bradley's side finally found their feet, and should have been well ahead by half-time, only to shoot themselves in the foot with some nightmare finishing.
Herculez Gomez should have done much better when the unmarked striker shot straight at busy keeper Mbolhi in the first in a long list of great chances.
Jozy Altidore then weighted in with a miss of the tournament contender, firing the rebound high and wide over an open goal after Mbolhi had pulled off another good save, a nightmare moment for the youngster to rival Yakubu's howler for Nigeria against Korea Republic.
When Dempsey hit the woodwork it looked like it wasn't going to be the States' day, but Donovan had other ideas to pop up with the most important goal of his career to clinch a place in the last 16 on Saturday.