Midfielder András Schäfer put Hungary 1-0 up with a header in the 37th minute of the game at the National Stadium in the Polish capital, but Karol Świderski equalized for Poland in the 61st after a corner kick.
Daniel Gazdag set the final score at 2-1 for the visitors in the 80th minute when he smashed the ball home from inside the box after an error by the home team's defence.
The Poles, under their Portuguese manager Paulo Sousa, went into the match missing several key players, including star striker Robert Lewandowski, who had been given time to rest amid a busy run of games.
Poland are ranked 23rd worldwide by football's governing body FIFA, while Hungary are No. 43 in the FIFA table.
After 10 rounds of fixtures, Poland finished second in their qualifying Group I, behind England, with 20 points, and will now take part in the 12-team playoffs in March that will decide who joins the 10 European qualifying group winners at the World Cup in Qatar.
All group winners in European qualification automatically secured a place at the 2022 World Cup in Qatar. The 10 group runners-up will have a second chance to advance through the playoffs.
The playoff draw will be held at FIFA headquarters in Zürich, Switzerland on November 26.
The tournament will be held in Qatar from November 21 to December 18, 2022.
(gs)
Source: PAP, Polsat Sport