Morocco's final group game against Iraq in Patras' Pampeloponnisiako Stadium ended in a narrow 2-1 victory. Tragically for the Moroccans, Costa Rica's 4-2 defeat of Portugal saw the Ticos draw level with the North Africans on goal difference and claim the second quarter-final berth by virtue of a superior goalscoring record.
Iraq made a number of changes to their starting line-up, giving Attiya Saad and Salah Ahmed their first taste of Olympic action and leaving six players who featured in the first two games, including two-goal striker Mohammed Hawar Mulla, on the bench.
The first chance of note went to Iraq after five minutes when the unmarked Farhan Razzaq headed an Ahmed Salah cross just wide of the target from eleven yards. Nine minutes later, it was Salah who raced onto a through ball to find himself one on one with goalkeeper Nadir Lamyaghir. Salah actually beat the onrushing keeper, but his lob was headed clear by Jamal Alioui who had tracked back. Iraq had an abundance of opportunities and dominated the early stages with Morocco struggling to make an impact.
The North Africans finally began to make their presence felt midway through the first half, registering their first shot in anger on 23 minutes when Bouchaib El Moubarki curled a free-kick narrowly over the bar from 18 yards. Two minutes later, they broke down the left. Bouabid Bouden headed down a high cross for Bouchaib El Moubarki, whose volley was held by the Iraqi goalkeeper.
This more aggressive approach began to pay handsome dividends for the Moroccans as they created chance after chance. Iraq responded five minutes before the break through a Salah Ahmed effort from a tight angle.
Morocco came out revitalised for the second half, with Bouabid Bouden crashing a shot against the post from an acute angle on 55 minutes. The North Africans continued to create openings at will, shooting at every opportunity.
But it was Iraq who eventually broke the deadlock on 63 minutes. Mohammed Emad, recently introduced as a substitute, broke down the right before pulling the ball back to Sadir Salih, who met the ball first time to hand his team a 1-0 lead.
Morocco immediately pressed for an equaliser and earned their chance after 69 minutes when referee Horacio Elizondo awarded a penalty for a foul. Bouabid Bouden converted at the second attempt to draw the score level at 1-1.
The North Africans sustained their onslaught and soon struck again. Merouane Zemmama broke into the penalty area down the right-hand side and pulled back a cross from the by-line which was met the surging run of Salaheddine Aqqal, who made no mistake in slotting into an empty net from three yards.
Iraq could have equalised in the final minute, but Munir Qusai's dipping header came down onto the crossbar.
Morocco coach Mustapha Madih was disappointed with the final outcome. "That's football. We have to accept it. After going 2-1 up, we were sure that we were through, but then Costa Rica scored in the last minute."
Iraq's coach Adnan Hamd was pleased with his team's performance despite the defeat: "I gave a few players the chance to play at an Olympic Football Tournament today. The quarter-final against Australia will obviously not be easy, but I think we can progress."