FA Cup: Man City 0 Middlesbrough 2
The Championship's second-placed side absorbed sustained first-half pressure, with normally second-choice goalkeeper Tomas Mejias making a string of impressive saves at the Etihad Stadium.
And Middlesbrough's resilience was rewarded as City produced some shambolic defending for Bamford to strike in the 53rd minute.
Aitor Karanka's team almost doubled their lead when the excellent Lee Tomlin struck the post before substitute Kike sent a packed away end into raptures by sealing victory in injury time.
City, who arrived back in Manchester on Friday evening following a training break in Abu Dhabi, appeared jaded as their performance unravelled.
Frank Lamapard came off the bench to strike the post after 89 minutes but back-to-back, scoreless home defeats means manager Manuel Pellegrini and his players head into next weekends pivotal clash at Bamford's parent club with a season to salvage.
The visitors made a confident and stylish start, though they were almost undone in the fifth minute when Stevan Jovetic was inches away from converting Aleksandar Kolarov's cross.
Middlesbrough had the ball in the net after 19 minutes - Lee Tomlin heading home after Willy Caballero kept out Bamford's flick - but the latter was penalised for offside.
Sergio Aguero's first sight of goal arrived five minutes later as his skipped around Ben Gibson to drill into the side netting.
The hosts' recent problems defending set-pieces were almost exposed when Daniel Ayala's free header from a 26th-minute corner was scrambled clear before City piled on relentless pressure for the remainder of the first half.
A busy period for Middlesbrough goalkeeper Mejias began with him beating away a low drive from Jovetic and he produced similar heroics to deny James Milner after the England international crossed for recalled centre-back Dedryck Boyata to thrash wastefully over.
Mejias was at full stretch to keep out David Silva's deflected 37th-minute strike before frustrating Jovetic once more.
The Montenegro forward found himself in the familiar position of being denied by Mejias as he headed goalwards from Kolarov's 50th-minute corner before some calamitous defending from City handed Middlesbrough the lead.
Fernando played an ill-advised backpass under pressure and Caballero missed his kick, leaving Bamford to scramble over the line.
A poor Caballero clearance gave Middlesbrough a glorious chance to increase their advantage in the 57th minute but the goalkeeper recovered to save from Tomlin and a desperate block by Vincent Kompany kept out Grant Leadbitter's follow-up.
Aguero glanced wide from a Navas centre but City's early poise had disappeared - Albert Adomah failing to lob the ball over Caballero after Tomlin's lofted pass easily unlocked a creaking home defence.
Tomlin went even closer himself in the 64th minute when he spun clear of Kompany to send Caballero the wrong way and stab a shot against the inside of the right-hand post - the rebound rolling agonisingly across the face of goal.
Middlesbrough defender George Friend made an important 73rd-minute challenge to deny Aguero, moments before the visitors streamed forward on the break and Caballero kept out a Jelle Vossen volley.
Lampard's shot clipped former City youngster Adam Clayton and hit the upright but Bamford then drove Middlesbrough forward on the break and fed Kiki, who ensured his team-mates would not rue their profligacy.