George Byers put the bottom of the table Wednesday ahead in the first half at St Andrew’s.
But the lead was quickly wiped out by Juninho Bacuna moments later.
Substitute Jordan James grabbed the 81st-minute winner, to the immense relief of former Manchester United and England striker Rooney, who managed just a single point from his opening five fixtures.
Wednesday’s 13th defeat this term leaves them 10 points from safety, while Birmingham moved into mid-table.
Jamie Vardy scored twice as leaders Leicester beat Watford 2-0 at the King Power Stadium, ending their run of two successive defeats.
Substitute Vardy broke the deadlock in the 76th minute and then added a second from the penalty spot deep into stoppage-time after being brought down by Hornets goalkeeper Daniel Bachmann, who was sent off for a second yellow card.
West Bromwich Albion inflicted second-placed Ipswich’s second defeat of the season as Darnell Furlong and Grady Diangana secured a 2-0 victory at the Hawthorns.
Fourth-placed Southampton had to settle for a 1-1 draw at lowly Huddersfield.
Ben Jackson salvaged a point for the Terriers with an 87th-minute equaliser after Adam Armstrong opened the scoring with his 10th goal this term.
In a dramatic late twist at Deepdale, Karlan Grant and Ike Ugbo scored in stoppage time as Cardiff snatched a 2-1 victory over 10-man Preston.
Ugbo struck the winner nine minutes into stoppage-time, three minutes after Grant cancelled out Milutin Osmajic’s opener.
Preston had Robbie Brady sent off shortly after taking the lead.
Mark Sykes’ strike earned Bristol City a 3-2 success over Middlesbrough in Liam Manning’s first home game as head coach.
Sammie Szmodics’ 11th goal of the season helped Blackburn to a 3-0 victory at Stoke.
Elsewhere, Plymouth beat Sunderland 2-0, Swansea and Hull drew 2-2 and Coventry triumphed 3-0 at Millwall to register a first victory in seven outings.
Second-bottom QPR’s winless run was stretched to 12 matches by a 1-0 loss at Norwich.
AFP