Midfielder Sebastian Szymański opened the scoring for Poland with a long-range shot after a set piece following a scramble three minutes into the game at the National Stadium in Warsaw.
Tim Matavž equalised for Slovenia with a precise finish from inside the box 11 minutes later.
Captain Robert Lewandowski put Poland 2-1 ahead in the 54th minute after a brilliant solo effort during which he dribbled past several Slovenia players before beating star goalkeeper Jan Oblak.
But Slovenia hit back and drew level with a goal from Josip Iličić seven minutes later.
Jacek Góralski put the score at 3-2 in Poland's favour in the 81st minute.
The hard-fought home win marked the close of a successful qualifying campaign for Poland, who had previously sealed a spot in Euro 2020 and celebrated advancing to the European championships for the fourth time.
The Poles finished top of their qualifying Group G on 25 points, six more than Austria, who also booked a berth in next year’s tournament.
The Euro 2020 tournament will be held from June 12 to July 12, 2020 in 12 cities around Europe.
Poland in 2016 made it through to the quarterfinals of the European championships in France, losing to Portugal on penalties.
Defender Łukasz Piszczek played his farewell match for Poland on Tuesday, earning 66 caps for the national team and receiving a standing ovation from fans.
(gs/pk)
Source: Polsat Sport
Click on the audio icon above to listen to a report by Radio Poland's Tomasz Ferenc.
Source: Polsat Sport