Ronan Hayes and John Hetherton proved to be supersubs for Dublin, their impact off the bench in the second half proved decisive as the visitors came from behind to end Galway's winning run in the Leinster Hurling Championship.
Dublin used direct long balls when the pair were introduced and they caused the Galway defence untold difficulty.
But it seemed that Galway had done enough to secure their place in the Leinster final when Colm Molloy levelled the game in the fourth minute of stoppage time.
However, another long ball was taken superbly by Brian Hayes and he blasted to the net before Cian O'Sullivan sealed the win in the final play.
Dublin won the toss and opted to play against the wind on a wet afternoon in Salthill and at half-time they trailed by just three points against a wasteful Galway side.
Galway, having hit 19 wides against Kildare, clocked a dozen by the break and had to be content with a lead of 0-11 to 1-05.
Despite losing impressive newcomer Rory Burke to injury before the game, with Tom Monaghan coming in having impressed off the bench against Kildare, the Tribe raced into a three-point lead in the opening seven minutes thanks to a couple of frees from Aaron Niland and a good one from play from Cian Daniels.
Dublin got a huge break with their opening score after 13 minutes when a 65, awarded after a superb save from goalkeeper Darach Fahy to deny Brian Hayes, ended up in the net when Daithi Burke tried to take down Donal Burke’s effort but knocked into the net.
Conor Ó Riain, one of three late changes with Eoghan O’Donnell, Darragh Power and Hetherton not starting, edged them in front moments later and they took that lead into the closing eight minutes of the half as Galway’s wide count mounted.
Padraic Mannion landed his second point from wing-back as Galway finished the half with four points without reply, but it took another fine save from Fahy, this time from David Purcell, and a clearance off the line from Ronan Glennon to prevent a second Dublin goal before the break.
Galway, who finished 17 wides to Dublin’s three, continued to hold their lead for the third quarter, despite losing Niland to injury, with sub Darragh Neary doing well and Monaghan landing two more.
Galway led by four points with twelve minutes remaining before Dublin rallied. Donal Burke, who finished with 1-9, pulled back a point and then Hetherton set up Hayes for a goal to tie the sides at 2-13 to 0-19.
Ronan Hayes edged Dublin in front and Burke pointed a 65 but as the game slipped into injury-time Cathal Mannion cut the gap to a point with a free and then in the 74th minute sub Molloy levelled.
That would have been enough to secure a place in the Leinster final but the Hayes brothers had other ideas as they struck for the winner in the dying moments.
Dublin: Eddie Gibbons; Conor McHugh, Paddy Smyth, Paddy Doyle; Chris Crummey, Liam Rushe, Conor Burke (0-01); Conor Groarke, Brian Hayes (1-00); Fergal Whitely, Donal Burke (1-09, 0-07f, 1-01 ’65), Conor Donohoe (0-01); Conal Ó Riain (0-02), Cian O’Sullivan (0-01), David Purcell.
Subs: John Hetherton for Groarke (51), Ronan Hayes (1-02) for Purcell (56).
Galway: Darach Fahy; Ronan Glennon, Cillian Trayers, Darren Morrissey; Padraic Mannion (0-02), Daithí Burke, Gavin Lee; Cian Daniels (0-01), Tiernan Killeen; John Fleming, Cathal Mannion (0-04, 0-03f, 0-01 ’65), Aaron Niland (0-05, 0-04f); Jason Rabbitte (0-01), Conor Whelan (0-02), Tom Monaghan (0-03).
Subs: Darragh Neary (0-02) for Niland (39), Joshua Ryan for Trayers (64), Colm Molloy (0-01) for Fleming (65), Cianan Fahy for Daniels (67), Oisin Lohan for Killeen (74).
Referee: Colm Lyons (Cork).