An injury-time goal by Troy Parrott to complete his hat-trick booked Republic of Ireland a spot in the playoffs for next year’s World Cup with a thrilling 3-2 comeback victory over their nearest Group F rivals Hungary in a must-win game in Budapest.

Higher-ranked Hungary just needed a draw to secure second place and led 2-1 at half-time thanks to goals from Daniel Lukacs and Barnabas Varga, but Parrott’s second goal of the night on 80 minutes and last-gasp winner broke the home side’s hearts.

“I said against Portugal that this is what dreams are made of, but I think tonight, I will never have a better night in my whole life,” Parrott said. “It is a fairytale. You can’t even dream about something like that. I have no words to describe the emotions right now.”

Hungary, who unlike Ireland have made the finals of the last three European championships, got off to the perfect start when Lukacs flicked in a Dominik Szoboszlai short corner on four minutes, only for Parrott to equalise from the penalty spot on 15 minutes.

Caoimhin Kelleher kept the sides level with a fine close range save from Roland Sallai but could do nothing on 37 minutes when striker Barnabas Varga chested the ball down with his back to goal just outside the box, swivelled and unleashed a stunning left-foot half volley into the top corner.