England made it six wins from six qualifying matches but fell behind to Milivoje Novakovic’s fifth strike of the campaign on 37 minutes at the Stadion Stozice.
Jack Wilshere drove in his first international goal to equalise after the break and he again found the net 17 minutes from time. There was then late drama as substitute Nejc Pecnik levelled for the hosts before Wayne Rooney struck the winner.
England went close three times – twice through Raheem Sterling and once through Rooney – before, as they did in November’s 3-1 home win, conceding against the run of play.
Novakovic it was who landed the first blow, the 36-year-old exchanging passes with Josip Ilicic before taking advantage of England’s lack of defensive shape to calmly fire past Joe Hart for his 30th international goal.
The hosts packed their defence after the break, but 12 minutes after the restart England struck back. A run from Adam Lallana – half-time substitute for the injured Phil Jones – was halted in the area, yet the ball was only cleared as far as Wilshere, whose drive from just outside the box brushed goalkeeper Samir Handanovic’s fingers before finding the top corner.
With the hosts rattled, Rooney then missed two chances in two minutes, but England went ahead when Lallana flicked a lay-off to Wilshere, who crashed in an unstoppable effort from outside the area. The visitors pushed to kill the game off, but Pecnik conjured a header from Bojan Jokic’s cross to level things up on 84 minutes.
However, there was a sting in the tail for the hosts two minutes later as Jordan Henderson’s pass was diverted into Rooney’s path, and the Manchester United FC forward kept his composure to send Handanovic the wrong way and bring himself level with Gary Lineker on 48 England goals, just one behind Bobby Charlton’s record of 49.