England’s captain hit an 85th-minute winner to move level with Gary Lineker and one behind Sir Bobby Charlton on England’s all-time leading goalscorer list and hand his country their first unbeaten season in 24 years.
But things had not gone quite to plan for England as Slovenia, just as at Wembley in November, took the lead thanks to Milivoje Novakovic’s 37th-minute strike.
England hauled themselves back into the contest after the break courtesy of a superb Jack Wilshere double strike – his first goals in international football.
However, they were pegged back by former Sheffield Wednesday striker Nejc Pecnik with just six minutes remaining but Rooney was on hand to seal all three points and put Roy Hodgson’s men on the brink of qualification for France 2016.
England started brightly in Ljubljana and they could have gone ahead in just the fourth minute as Raheem Sterling was played through on goal, but the Liverpool forward lifted his shot over the bar.
Sterling, who put in a lacklustre display in the friendly against the Republic of Ireland last weekend, was in the thick of the action for the Three Lions as Rooney found him with superb curling outside of the boot pass, however, his low effort was deflected wide.
Hodgson’s men were pressing forward at every opportunity and they thought they’d gone ahead when Fabian Delph released Rooney into the penalty area. His shot was destined for the far corner but Samir Handanovic, who has been linked with a move to Manchester United, got down low to his left to tip the ball behind for a corner.
England were starting to turn the screw on Slovenia but one lapse in concentration cost Hodgson’s men as Chris Smalling and Gary Cahill got the offside trap all wrong, allowing Ilicic to slip the ball through to Novakovic, who had all the time in the world to pick his spot and beat Joe Hart for his 30th international goal.
Hodgson was forced into a change after the break as Phil Jones picked up an ankle injury and Adam Lallana was thrown on in central midfield with Jordan Henderson moving to right-back.
The visitors started the second 45 minutes in much the same vein as the first and their possession finally counted in the 57th minute when Wilshere powered his first international goal into the top corner with his left foot from the edge of the penalty area.
The turnaround was complete 16 minutes later as Wilshere picked out the same top corner with an even better left-footed strike to round off an excellent England move, involving superb inter-play between Andros Townsend, Henderson and Lallana.
England were in full control and seemed destined for all three points but again they were pegged back in the 84th minute when Pecnik rose above Kieran Gibbs at the far post to thunder a header into the bottom corner.
But minutes later Rooney stormed through on goal before sending Handanovic the wrong way to net the winner and complete an unbeaten season for England for the first time since the 1990-91 campaign.
England now have 18 points from a possible 18 in Euro 2016 qualifying and can seal qualification when they take on San Marino and Switzerland in a Group E double-header in September.