Wayne Rooney endured a losing start to his first match in charge of Birmingham as Morgan Rogers' last-gasp strike snatched a 1-0 victory for Middlesbrough at the Riverside Stadium.
The 21-year-old Rogers had only been on the pitch 13 minutes when he fired home in the 89th minute to earn Middlesbrough a fifth straight Championship win.
The result moves Michael Carrick's side just one point behind his former team-mate Rooney's seventh-placed City, who lost for a fourth game in a row on the road.
It looked like the ex-Manchester United and England pair would have to settle for a point on Rooney's debut in the Birmingham hot seat, but substitute Rogers had other ideas.
- Championship fixtures | table | highlights
- Stream the Championship and more with NOW
- Get Sky Sports | Download the Sky Sports App
Middlesbrough had their chances, particularly in the first half, but had not found a way past John Ruddy in the Birmingham goal.
Rooney was greeted with a mixed reception on his return to an English touchline, with Boro's fans quick to direct a derogatory chant his way while the Blues' contingent chanted his name.
And he was a relieved man in the opening couple of minutes when Dion Sanderson's misplaced back pass went out for a corner that came to nothing.
Sanderson was also involved in unsuccessful penalty shouts from the home side. The defender, who had a spell on loan at Sunderland, brought down Matt Crooks after his touch went out of play but referee Rebecca Welch turned down appeals.
While Middlesbrough, who went close through Josh Coburn on occasions, did most of the attacking, Birmingham were first to seriously test the goalkeeper.
Seny Dieng was quick to dive to his left to prevent Krystian Bielik's low first-time effort from finding the bottom corner after some clever wing play from Siriki Dembele.
After that Coburn headed Dan Barlaser's free-kick over at the other end and Isaiah Jones had a goal ruled out for offside after he had been put through by the homegrown striker.
There was a second strong penalty shout waved away when Bielik appeared to bring down Jones, whose speed got him to the ball first when both players went for a 50-50.
The best chance of the half fell to Coburn just after half an hour. Hayden Hackney and Sam Greenwood combined before Coburn was played in but his scuffed shot bounced wide when he should have found the target.
Somehow it remained goalless despite Middlesbrough's first-half domination, even though Birmingham goalkeeper Ruddy was lucky not to concede after being caught on walkabout out of his box. He was booked for fouling Jones instead.
Soon after half-time Ruddy made two fine saves. First, he flew to his right to turn behind an effort from Hackney and then he reacted to hold Paddy McNair's goalbound touch following a corner.
Middlesbrough, who also had a rasping volley from McNair saved by Ruddy, continued to have more of the game but it looked like they would have to settle for a point until Rogers found the breakthrough with his first league goal for the club.
He arrived with a minute left to clip Crooks' low return pass inside Ruddy's near post to deflate Birmingham hopes.
The managers
Middlesbrough's Michael Carrick:
"It was a big goal for all of us - a big goal to win a game. I'm really pleased for Morgan, he came on to make an impact. Goals like that can give you a massive boost and I am sure he will have an impact for the rest of the season. We did enough to win the game because we had enough chances, and those chances we could have scored from, they were good ones. I couldn't fault the boys. It is tough when you go into a game like this because we didn't really know
what we were going into, there wasn't much we had to go on (after Rooney's arrival). But I'm really pleased about the impact from the boys off the bench. They have all come off and made an impact in different ways. You never know if a goal is going to come, but you have to keep doing the right things and freshen up to try to create a spark. In the end the boys found a way to score."
Birmingham's Wayne Rooney:
"I have been quite calm. You always have a feeling before the game as player or manager, which is normal, but I was quite calm. I know what I want. I know where we need to get to. I knew this was a possibility today, but it will take time to get where we want to go. We might have to go through days like this and it is important we stay calm to ensure we hit the goals we really want to. You never enjoy when you lose, but it is great to be back in English football, great to be at Birmingham. Thankfully we have another game Wednesday.
"There were parts of the game we wanted to take the ball more, but ultimately you don't always get what you want in football. It is decision-making and game management. Even after Middlesbrough scored there were different moments in the game were our game management has to be better. That is what frustrated me in the last eight minutes. But we are a team trying to adapt to a different way and that will take time. During that period we do have to pick up points."