It was white-knuckle stuff, it always is with Mayo.

They had the chances to put this one to sleep in the first half and as is their way they let them pass in this Super 8s thriller.

For them it always has to be in the melting pot until the end and that's the way it was on an electric evening at Elverys MacHale Park as they squeezed past a Donegal team to book their place in the All-Ireland semi-final next Saturday.

With age and injuries threatening to finally catch up with this bunch of warriors they once again refused to die.

The odds are stacked against them the next day regardless of who their opponents are - it's likely going to be five in-a-row chasing All-Ireland champions Dublin - but they simply can’t be counted out.

It’s cruel on Donegal - this is the first game that they’d lost in a summer season that included an Ulster title while Mayo have lost twice on their way to the final four. That’s the way the system works though and James Horan’s team worked it perfectly.

Coming to Croke Park next weekend they may have to do without Jason Doherty, who went down in a heap after three quarters of an hour, but dynamic midfielder Mattie Ruane made his first appearance since breaking a collarbone following the Connacht semi-final defeat to Roscommon.

Tom Parsons, who hasn’t kicked a ball in anger since blowing out his knee in last year’s loss to Galway, was on the bench - a remarkable comeback and a boost to his team mates.

In a helter-skelter finish in front of 27,023 fans in Castlebar they held their nerve, pushing their lead out to four points, led by veteran attacker and former Footballer of the year Andy Moran, while Donegal lost their way when they got near the target at the other end.

Donegal lined out as advertised and there were two changes on the Mayo team to the side that appeared in the programme, Keith Higgins and Patrick Durcan in for Eoin O’Donoghue and Fergal Boland.

Both managers had their plans upset early on though, Donegal midfielder Jason McGee gone after just 10 minutes injured and Mayo’s Higgins following him not long after when he picked up a black card for pulling down Patrick McBrearty.

The match-ups in this one were fascinating and Horan decided to hammer the hammer, putting former Footballer of the Year Lee Keegan on Michael Murphy and Patrick Durcan on the hugely influential Ryan McHugh and neither of the visitors’ main men got a sniff early on.

The Ulster champions took a two-point lead after two minutes and in the rest of the 35 minutes that was played in the first half, including stoppage time, they only managed a further two, both from Murphy frees.

Mayo played the kick-out game well at both ends of the field, alternating between letting Donegal take them short and then meet them just across the half-way line where they usually turned them over with ferocious tackling, and squeezing them high up and making them sweat to get the ball out.

Goalkeeper Rob Hennelly got most of his away long, though he did have a wobble when he went short once and was lucky that Patrick McBrearty’s hand-pass went astray with the goal on.

Mayo led by 1-07 to 0-04 at half-time and it could have been much more, with two dropped short and seven sides, but it was still a decent cushion and just reward for their efforts.

The goal came seven minutes before the break when a wayward Jason Doherty effort dropped short and Cillian O’Connor was the first to react, catching his marker Paddy McGrath flat-footed and palming into the net.

Donegal went straight up the field and only a brilliant last-ditch tackle from Brendan Harrison on Jamie Brennan stopped him getting his shot away.

Murphy wasn’t going to be kept quiet forever though and he was sent straight into the edge of the Mayo square at the start of the second half. First ball in, a high one from Ciarán Thompson, Keegan was all over him and referee David Gough spread his arms.

He stuck the penalty himself and then it all started to happen. Yellow cards flashed after a row on the 20, Jason Doherty won the resulting kick-out but stumbled and stayed down clutching his knee. After 45 minutes when the centre-forward won ball brilliantly, carried bravely and kicked a point he was carted off and replaced by Kevin McLoughlin.

And what was the first thing that McLoughlin did? He bombed over a wonder point with his first touch to restore a four-point lead.

Murphy got his first from play shortly afterwards when Andy Moran, a first half sub, could have put this one to bed, but he sent his shot straight at keeper Shaun Patton in the Donegal goal and the ball swept up the field.

Donegal put the squeeze on Mayo's restarts and the home side were struggling for air, but Declan Bonner's side were uncharacteristically wayward with their shooting, even their captain and leader Murphy hitting a poor wide with better options on.

Mayo: Robbie Hennelly; Chris Barrett (0-01), Brendan Harrison, Keith Higgins; Lee Keegan, Colm Boyle, Stephen Coen; Aidan O’Shea, Séamus O’Shea; Fionn McDonagh, Jason Doherty (0-01), Patrick Durcan (0-03); Cillian O’Connor (1-04, 4f), Darren Coen, James Car (0-02).

Subs: Eoin O’Donoghue for Higgins 15 mins (black card); Andy Moran (0-02) for Darren Coen 25 mins; Kevin McLoughlin (0-01) for Doherty 45 mins; Fergal Boland for Carr 65 mins; Mattie Ruane for Séamus O’Shea 70 mins; James Durcan for O’Connor 75 mins.

Donegal: Shaun Patton; Paddy McGrath, Eamonn Doherty, Stephen McMenamin; Ryan McHugh, Daire Ó Baoill (0-02), Odhrán McFadden Ferry; Hugh McFadden, Jason McGee; Ciarán Thompson, Niall O’Donell (0-02), Jamie Brennan; Patrick McBrearty (0-02), Michael Murphy (1-04, 2f, 1-00 pen), Michael Langan.

Subs: Leo McLoone for McGee 10 mins; Paul Brennan for Doherty 31 mins; Caolan Ward for McGrath 41 mins; Oisín Gallen for Thompson 54 mins; Eoin McHugh for Paul Brennan 63 mins (black card); Eoin McGettigan for Langan 72 mins.

Referee: David Gough (Meath)