Stephen Griffin's injury-time point secured a 1-9 to 0-12 draw to seal Donegal's passage through to the Allianz Football League Division 1 semi-finals.
Rory Gallagher's team looked to be heading out at the expense of their hosts at MacHale Park in Castlebar. However, nine second half wides scuppered Mayo's chances.
The visitors were 1-5 to 0-7 in front at half-time with Paddy McBrearty grabbing what proved to be the only goal of the game on 19 minutes.
The Connacht champions, driven on by the influential Barry Moran, were within touching distance of the last-four as they led thanks to a free from Kevin McLoughlin three minutes from time.
And with Donegal streaming forward in search of a leveller, Patrick Durcan strode clear but instead of opting for an insurance point for Mayo, he went for goal and fluffed the effort as Michael Boyle made a simple save. In the end, Donegal fought back to earn a draw and claim fourth spot in the table, booking a semi-final date with Cork next weekend.
Mayo were left to rue those missed second half opportunities as they aimed to turn around their 1-5 to 0-7 interval arrears. The only goal of the game came midway through the first half, McBrearty finishing off a flowing move that was instigated by goalkeeper Boyle who picked out Martin McElhinney in midfield.
Christy Toye, Frank McGlynn and Martin O'Reilly were all involved before McGlynn fed McBrearty whose piercing shot flew past Kenneth O'Malley and into the top corner of the net.
Odhran MacNiallais was also in splendid form, kicking tree first half points - the first of which was landed after only 19 seconds. At the other end, Mayo, who were 0-2 to 0-0 down barely a minute in after McElhinney had doubled Donegal's advantage, clawed their way back into the contest with four successive points. Jason Doherty posted two of those, with Moran and McLoughlin also on the mark.
And after McBrearty’s goal, the home side finished the half strongly, with Moran, Donal Vaughan and Aidan O'Shea finding their range.
Mayo continued to press after the interval and despite a spate of missed chances, looked to have done enough to squeeze their way through. Moran, with his third of the afternoon, pointed with Diarmuid O'Connor, a late inclusion in attack, Mikey Conroy and McLoughlin also scoring.
Without the suspended Michael Murphy, Donegal, for spells in the second period, looked to be missing the apex of their attack. McBrearty did a decent job with very limited supply and was unfortunate to see what would have been a second goal on 43 minutes ruled out for a push.
A frantic finish saw Vaughan dismissed for adding a black card to his earlier yellow before Griffin pulled it from the fire for Donegal in the fourth minute of injury-time.
It was Donegal's first point on the road in the league's top flight since 2009, but of more immediate importance for manager Gallagher it will gave his side a run-out at Croke Park against Cork prior to their Ulster SFC preliminary round clash with Tyrone in Ballybofey on May 17.
MAYO: K O'Malley; B Harrison, K Keane, K Higgins; L Keegan, C Boyle, D Vaughan (0-1); B Moran (0-3), S O'Shea; K McLoughlin (0-3, 0-1f), A O'Shea (0-1), J Doherty (0-2, 0-2f); M Ronaldson, D Kirby, D O'Connor (0-1).
Subs used: M Conroy (0-1) for Ronaldson (half-time), S Coen for Harrison (45 mins), A Moran for Kirby (55), P Durcan for Boyle (65), N Douglas for McLoughlin (70), M Hall for O'Connor (black card, 70).
DONEGAL: M Boyle; N McGee, E Doherty, P McGrath; E McGee; K Lacey, R McHugh; O MacNiallais (0-3), H McFadden; M McElhinney (0-1), C Toye, F McGlynn; C McFadden (0-1), P McBrearty (1-3, 0-1f), M O’Reilly.
Subs used: C McGinley for Toye (42 mins), A Thompson for Doherty (42), M McHugh for H McFadden (black card, 48), S Griffin (0-1) for McGinley (59).
Referee: David Coldrick (Meath).