Mayo booked their place in the Division One semi-finals as they kept Dublin scoreless for the entire second half in a 0-10 to 0-09 defeat of the Leinster champions in Castlebar.
The Dubs were well on their way to recording their fourth league win as they led 0-09 to 0-04 at half-time.
But Conal Keaney, who registered three first half points, was sent off just four minutes after the break and Mayo took their cue.
Andy Moran, David Heaney, Conor Mortimer (0-03) and Alan Dillon pointed the westerners in front before Dublin substitute Diarmuid Connolly hit a late penalty off the post, after Keith Higgins had fouled Jason Sherlock.
Despite playing with the wind at their backs, Dublin were left trailing by 0-03 to 0-02 by the midway stage of the first half. Keaney had opened the scoring with a third-minute point while Kevin Bonner had also floated a score over Kenneth O’Malley’s crossbar.
Mayo replied with a Mortimer free and Austin O’Malley and former captain Heaney also fired over points on the run. But with Darren Magee and Ciaran Whelan having a big say in midfield, Dublin moved menacingly into a ‘double scores’ lead.
Points from Keaney (0-02) and a ‘45’ from Tomas Quinn saw to that. It got even better for Paul Caffrey’s men when Colin Moran and Bernard Brogan made it 0-08 to 0-03 in the visitors’ favour, before Aidan Kilcoyne and Barry Cahill, who cracked over a great point from distance, exchanged overs late in the half.
Dublin’s interval lead was hardly unassailable and Mayo were given an early avenue back into the game when Keaney fell foul of referee Michael Hughes and was dismissed in the 39th-minute.
From then on, Mayo took control with Moran, Heaney, Mortimer (0-02) and Dillon firing over scores before a Mortimer free gave the Connacht champions a single-point lead.
Drama followed in injury-time when the advancing Sherlock was brought down by a clumsy challenge from Higgins.
Connolly took on the responsibility of taking the kick but despite beating substitute goalkeeper David Clarke with his shot, the agony was etched all over the St Vincent’s youngster’s face as he watched the ball bounce back off the left post and Mayo managed to scramble the rebound away to safety.