Hungary defender Hanna Nemeth struck the winner in the fourth minute of added time after Simone Magill's late penalty appeared to have rescued Northern Ireland a point in Gyor.
Caragh Hamilton's late header cancelled out Viktoria Szabo's first-half opener for Hungary, who had regained the lead through Dora Sule's stunning long-range effort.
Hungary leap-frogged Tanya Oxtoby's side into second place in the UEFA Women’s Nations League table, with the two Group B1 rivals set to meet again in Belfast on Tuesday.
Hungary took an 18th-minute lead when Szabo's cross from out wide on the left curled over Shannon Turner and landed inside the far post.
Zsanett Kajan's low angled shot struck the woodwork and in the second half Turner superbly tipped Evelin Fenyvesi's fierce drive on to a post.
Substitute Hamilton headed the visitors level with her first touch in the 81st minute.
Hungary regained the lead less than a minute later through Sule's 35-yard shot before Magill equalised from a penalty in the 89th minute.
But just as it looked like Northern Ireland had rescued a point on the road, Nemeth's outstretched boot connected with a free-kick into the box in the fourth minute of added time.