Marcell Jansen opened the scoring for Hamburg only for Schurrle to equalise 11 minutes into the second half.
The hosts went ahead again after 59 minutes through Mladen Petric, but Gojko Kacar's own goal levelled matters once more.
Schurrle then struck a second time in the 82nd minute to put the visitors in front before Florian Heller made certain of the win two minutes from time.
Mainz collected their ninth away victory to move on to 43 points - just four behind third placed Hannover.
Hamburg took the lead after 17 minutes with a controversial goal as Jansen's left-footed drive hammered off the crossbar and downwards, although replays suggested the ball had not crossed the goalline.
Home goalkeeper Frank Rost then made two telling saves to deny Andreas Ivanschitz and keep his side ahead.
But Mainz equalised in the 56th minute as Malik Fathi crossed from the left to Schurrle, who headed in from nine yards out.
Hamburg reclaimed the lead just three minutes later with Jose Paolo Guerrero passing to Petric, who found the target from 11 yards.
However, Mainz hit back once more in the 61st minute through an own goal by Kacar, whose poor attempt at a clearance was instead directed past Rost.
It was an enthralling contest and Mainz took the lead for the first time with eight minutes left on a superb counter attack as Eugen Polanski played in Schurrle, who outpaced Kacar before chipping over the out-rushing Rost.
And the hosts rounded off the scoring on another counter attack when Schurrle raced down the right wing and crossed for Heller to stab home.