Steve McClaren's team had endless chances in the first half, but resolute defending by City, fine form from Alan Fettis and some poor finishing kept it goal-less.
City began to get into the game before half time, and a volley by Richie Appleby was well saved by Mark Schwarzer, before the Boro 'keeper denied Appleby minutes later with another shot.
City kept up the pressure after the break, and Jason Price had the best chance of the match to put Peter Taylor's side ahead. After work between Damien Delaney and substitute Ryan Williams on the left, Ben Burgess fed Jason Price with a throughball. After taking a touch he poked the ball past the approaching Schwarzer, but saw his effort go inches wide.
The game then petered out after numerous substitutions were made by both sides, before the visitors snatched a winner in the dying seconds when a low 20-yard drive by Doriva fired off the inside of the post and into Fettis' net.
City line-up (4-4-2): Fettis; Thelwell, Hinds, Joseph, Delaney; Price (Regan 62), Ashbee, Appleby (Keates 55), Elliott (Williams 55); Allsopp (Donaldson 79), Burgess (Webb 79).
Un-used subs: Musselwhite, Whittle, Peat, Melton.