Striker Troy Parrott was the hero, scoring a hat-trick that included a penalty, an equaliser, and the winning goal deep into stoppage time.
The win propelled Ireland into second place in Group F, keeping their World Cup dream alive and securing a spot in March's play-offs.
Ireland twice fought back from a goal down, with Hungary's goals coming from Daniel Lukacs and Barnabas Varga.
A tearful Parrott described it as the best night of his life, while manager Heimir Hallgrimsson viewed the success as a crucial step for Irish football's future growth.