A 48th Connacht SFC title - placing them one ahead of Galway in the overall roll of honour - didn't come without an epic struggle for Mayo who came roaring back from behind to steal the silverware at Croke Park.

Last year's All-Ireland finalists looked to be in trouble after conceding first-half goals to Shane Walsh and Damien Comer, leaving them five points down at the interval.

But a thrilling second-half performance, in which they outscored Galway by 1-3 to 0-0 in the third quarter and held them scoreless from play in the entire second-half, forced an 11-point turnaround by full-time.

Ryan O'Donoghue was terrific for Mayo and struck a goal from a 37th-minute penalty which got the fightback underway.

Man of the Match Matthew Ruane capped a terrific performance with Mayo's second goal in the 67th minute, leaving them in the clear.

There were huge performances too from Padraig O'Hora and Conor Loftus while Aidan O'Shea helped win Mayo's penalty with a great catch and lay-off. Tommy Conroy came into the game strongly in the second half too, scoring two important points.

Mayo's reward is a return to Croke Park in three weeks to face the Leinster champions, Dublin or Kildare, in the All-Ireland semi-finals.

Errors and injuries impacted both teams initially and at the end of a riveting first-half, Galway found themselves five points to the good and in pole position so will kick themselves for how things panned out.

By that stage, however, they'd lost both defender Sean Kelly and corner-forward Rob Finnerty to injuries.

The errors were more on Mayo's side with a number of decent scoring chances butchered by the 2020 provincial winners at the Hill 16 End.

O'Shea, playing at midfield, forced a great turnover on Walsh for instance in the 21st minute and picked out Conroy with a neat pass but the attacker was pulled for overcarrying.

Two minutes later, Stephen Coen claimed an advanced mark and sliced his kick badly wide.

In first-half stoppage time, O'Shea roamed into the full-forward position and pulled a great catch out of the air but turned and slammed face first into Sean Mulkerrin and the chance was lost.

Loftus had a great goal chance in stoppage time too but lacked composure and blazed his kick over.

Galway were more efficient at the other end and their two goals, in the 20th and 27th minutes, separated the teams in the opening half.

Mayo won't be overly pleased with the concession of the first as Paul Conroy's shot off the post bounced three times before Walsh collected the ball and slammed it to the net.

Walsh darted clear of three Mayo men down the right for the second goal, eventually feeding Comer in the middle to rocket a shot to the net.

The next rocket fired off was presumably by Mayo manager James Horan at half-time because his team were at a different level when they returned.

Galway simply couldn't live with the ferocity of Mayo's play, in all areas though particularly in attack where they carved up the Galway defence at times.

Ruane and Loftus were on top at midfield and it was Ruane that won a 37th minute penalty, collecting an O'Shea pop pass and then going down under the weight of Matthew Tierney's challenge.

O'Donoghue slammed to the net and Mayo had wiped out the six-point deficit entirely by the 48th minute.

Sub Kevin McLoughlin nudged them ahead and points from O'Donoghue and the much improved Conroy stretched the gap to three.

It was all too easy for Mayo who had an O'Donoghue goal controversially ruled out for a foul in the buildup.

The goal they needed to kill the game eventually arrived with three minutes of normal time remaining, Ruane taking off on a thrilling run and finishing to the net at the Davin End despite losing the ball from his grasp at one stage in the run.

Mayo: Rob Hennelly (0-01, 0-01 45); Lee Keegan, Padraig O'Hora, Michael Plunkett; Patrick Durcan (0-01), Oisin Mullen, Stephen Coen; Matthew Ruane (1-02), Conor Loftus (0-02); Bryan Walsh, Aidan O'Shea, Diarmuid O'Connor; Tommy Conroy (0-02), Darren McHale (0-01), Ryan O'Donoghue (1-03, 1-00 pen, 0-01f).

Subs: Eoghan Mclaughlin for Walsh (h/t), Kevin McLoughlin (0-01) for McHale (h/t), Jordan Flynn for Loftus (45-51), Rory Brickenden for O'Hora (57- f/t, blood), Enda Hession for Plunkett (64), James Carr (0-01) for O'Shea (68), Conor O'Shea for O'Connor (76).

Galway: Connor Gleeson; Sean Mulkerrin, Dylan McHugh, Liam Silke; Kieran Molloy, Sean Kelly, Johnny Heaney; Paul Conroy (0-02), Matthew Tierney (0-04, 3 frees); Peter Cooke, Cathal Sweeney (0-01), Paul Kelly; Robert Finnerty, Damien Comer (1-00), Shane Walsh (1-01).

Subs: Finnian O'Laoi for Finnerty (17), Jack Glynn for Sean Kelly (26), Michael Farragher for Sweeney (51), Eamonn Brannigan for Paul Kelly (57), Johnny Duane for Walsh (72).

Referee: Conor Lane (Cork).