The Republic of Ireland secured a Euro 2012 play-off spot as they held off Armenia in a tense final qualifier.
Armenia settled better but they were dealt a huge blow when keeper Roman Berezovsky was harshly sent off for handling outside the box on 30 minutes.
The Republic took the lead on 43 minutes after Valeri Aleksanyan haplessly poked into his own net.
Richard Dunne hit the Republic's second on goal on 59 and Kevin Doyle was sent off after Henrikh Mkhitaryan's strike.
Armenia, knowing that victory would earn them the play-off spot ahead of the Republic after three recent high-scoring wins, showed no sign of nervousness at the start.
Dangerman Mkhitaryan shot wide after breaking dangerously towards the edge of the Irish penalty area in the fourth minute as the fluent Armenians dominated the early possession.
Against the run of play, Doyle fired straight at keeper Berezovsky in the 12th minute but the Irish were soon grateful for Yura Movsisyan's heavy touch as he attempted to round Shay Given following a Marcos Pizelli pass.
Cox had the ball in the Armenian net in the 25th minute and by the letter of the law the goal should have stood.
The Irish striker and keeper Berezovsky competed for a Stephen Kelly cross but the Armenian, thinking he had been fouled, immediately dropped the ball and with him seeking treatment Cox tapped the ball into the empty net.
It was only then that Spanish referee Eduardo Iturralde Gonzalez awarded the free-kick to avert the possibility of a controversy.
However, keeper Berezovsky's luck ran out massively five minutes later when he was red-carded after Gonzalez adjudged - incorrectly it appeared - that the keeper had handled a Cox shot outside the box.
Replays showed Berezovsky blocking the shot with his chest but the referee had made his decision and uncapped Arsen Petrosyan had to be introduced with holding midfielder Edgar Malakyan sacrificed.
To increase the Armenians' sense of injustice, Cox appeared to have had himself handled in controlling the long ball over the top of the defence.
The replacement keeper had a nervy opening as he was soon yellow-carded for handling outside the area and he was picking the ball out of his own net three minutes before the break after Aleksanyan's bizarre own goal.
Doyle failed to make contact with his attempted back-heel after a Duff cross but Aleksanyan hopelessly lost his bearings as he poked into his own net from two yards out.
After all the early tension, the Republic were suddenly a goal and a man up by the half-time interval.
The Republic's passing was far more assured in the 15 minutes after the break against a seemingly rattled Armenian outfit.
And the contest appeared over in the 59th minute as Dunne bundled in the Republic's second goal with his thigh after the replacement keeper had hopelessly flapped at a McGeady cross.
But three minutes later Mkhitaryan's low shot beat Given from the edge of the penalty area after good work by Movsisyan, offering Armenia renewed hope.
McGeady had a chance to kill off the Armenians in the 67th minute but was tentative with his shot and the winger was immediately hauled off with Stephen Hunt introduced.
Republic nerves were strained further when Doyle received his red card nine minutes from time after leading with his elbow in an aerial duel with Karlen Mkrtchyan.
Both sides had late half-chances as the Republic held on to secure their play-off games on 11 and 15 November.
Republic of Ireland: Given (capt), O'Shea, Dunne, St Ledger, S Kelly, McGeady (Hunt 68), Whelan (Fahey 76), Andrews, Duff, Doyle, Cox (Walters 80). Subs not used: Westwood, Coleman, Long, O'Dea.
Sent Off: Doyle 81
Booked: Kelly, St Ledger, McGeady, Doyle, Duff.
Armenia: Berezovsky, Hovsepyan, Mkrtchyan, Pizelli (Manucharyan 53), Malakyan (Petrosyan 28), Ghazaryan (Sarkisov 66), Movsisyan, Mkoyan, Aleksanyan, Mkhitaryan, Hayrapetyan. Subs not used: Yuspashyan, Artur Edigaryan, Artak Edigaryan, Badoyan
Sent Off: Berezovsky 26
Booked: Petrosyan, Aleksanyan
Referee: Eduardo Iturralde Gonzalez (Spain)