But having been played in by Elano, Richards lost his footing and his shot was comfortably gathered by keeper Frank Rost.
As City pressed forward they were vulnerable on the counter-attack and Hamburg made the task even harder for Mark Hughes' side with a 10th-minute goal.
Jonathan Pitroipa, who had begun the game well, found space on the right wing and his low cross was not dealt with by Dunne, the ball eventually finding its way to Guerrero who fired low past Given.
It meant that City now needed three goals just to force extra-time and they went some way to achieving that task with a 15th-minute equaliser.
It came from the penalty spot through Elano after his 20-yard effort had been handled by Piotr Trochowski. It looked a harsh decision with the Hamburg man knowing very little about the shot.
Trochowski then had two half-chances in quick succession, with Hamburg looking comfortable and composed on the ball.
City played with intensity and pace though, with Stephen Ireland and Caicedo having chances of their own, but the closest they came to taking the lead was on the stroke of half-time when Elano crashed a thunderous free-kick against the crossbar after Robinho had been fouled.
Five minutes after the restart, City reduced the aggregate deficit further with Caicedo making it 2-1 on the night.
The impressive Ireland provided the pass but Caicedo made the goal when he received the ball on the edge of the area and stepped inside his marker, showing neat footwork before firing low past Rost from 12 yards.
The goal spurred City on further as the Hamburg defence looked increasingly nervous and vulnerable.
And just five minutes later City were almost level when Elano smashed the ball against the post from another free-kick.
From the resulting corner Rost fumbled into the path of Caicedo but he fired over from just five yards out with the goal at his mercy.
On the hour, Hamburg had Rost to thank for keeping the score at 2-1, saving brilliantly from Robinho's close-range volley.
Minutes later Caicedo, who was giving the Hamburg defence a torrid evening, had the ball in the net but it was ruled out for offside as City edged closer to a crucial third goal.
Robinho went close with a near-post header with 25 minutes remaining as the Hamburg defence dropped deeper.
Manchester City's task was made harder with the sending off of Dunne, who was given his marching orders for two bookable offences.
City's captain was a persistent offender throughout the game and could have no complaints, having been booked early in the first half.
With a man advantage Hamburg's Dennis Aogo forced a fine low save from Given as City looked to reorganise themselves following Dunne's departure.
Seven minutes remained when Given saved well with his feet from Ivica Olic's close-range shot, and Richards then had a brilliant opportunity to send the tie into extra-time but he fired a volley high over Rost's goal.
In the final minutes, substitute Daniel Sturridge fired a shot into the side-netting and Hamburg held on to set up a semi-final with fellow Germans Werder Bremen.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.