Ivory Coast also advanced to Thursday's semifinals with a 5-0 victory over Guinea.
Ghana looked to be in trouble when captain John Mensah was sent off for a straight red card for a professional foul in the 60th minute, but Agogo, who now plays for Nottingham Forest in the third level of English soccer, scored the winning goal when he scored off Sulley Muntari's feed from the left.
Ayegbeni Yakubu scored on a penalty kick for Nigeria in the 34th minute, but the Black Stars evened the score on Michael Essien's header shortly before halftime.
"I'm just happy that we got through," Agogo said. "For me personally, I am buzzing that we are through. I can't believe it's true."
Salomon Kalou, Essien's Chelsea teammate, scored twice in the second half for Ivory Coast, which put its game away with four goals after halftime.
Abdelkader Keita opened the scoring in the 25th minute, and captain Didier Drogba and substitute Bakary Kone also scored in the second half