Spanish defender Daniel Ayala headed in his seventh of the season to secure the points for Tony Pulis’ side despite an early scare from the Robins.
Bristol City, who are now four points shy of the top six, took the lead in the ninth minute when Milan Djuric volleyed in.
But Middlesbrough, who controlled the game for long periods without threatening enough, levelled through George Friend nine minutes later.
After striker Patrick Bamford had to be stretchered off and taken to hospital midway through the first half, Middlesbrough moved up into the play-off spots by delivering the points courtesy of Ayala’s headed 22 minutes from time.
It was a big opportunity for both teams in the battle for a play-off spot because of Millwall’s draw with Sheffield United in the lunch-time kick-off.
When Middlesbrough started brightly it looked like they would be the team to get the goals rolling, only for Bristol City to stun the Riverside.
Jonny Howson had dragged a low effort wide before the visitors effectively scored with their first meaningful attack.
Mo Besic should have done better with a dropping ball on the edge of his area where Marlon Pack jumped higher to nod into the box.
There should still have been enough red shirts around to deal with it but Djuric reacted quickest to arch his body and volley low inside Darren Randolph’s far corner after getting in between Ayala and Friend.
It would be harsh to suggest Friend was at fault but he was the man to make amends nine minutes later when he jumped in the penalty area to glance an Adama Traore corner inside the far post.
That provided Middlesbrough with the lift they needed. The controlled the rest of the half, before and after the clash with Aden Flint which left Bamford requiring oxygen and being stretchered off just after the half-hour mark.
Despite 11 minutes added on at the end of the opening period, there was to be no breakthrough before the second half on a day when both teams needed the victory.
Middlesbrough had plenty of possession and yet could not do enough with it and City goalkeeper Frank Fielding was relatively quiet.
Adam Clayton, playing in place of the suspended Grant Leadbitter, blasted an effort over from distance while Britt Assombalonga headed wide but that was all they could muster before the hour mark.
Had Friend not been in the right place to block a low goalbound drive from Josh Brownhill then Middlesbrough would have been behind.
But then Brownhill suffered further frustration at the other end when he was unable to clear Ayala’s header from Traore’s corner off the line as Middlesbrough took the lead.
There was still one last chance for Bristol City to claim a point but Bobby Reid powered over an effort from 12 yards.