Bundesliga: Hamburg 1 Bayern Munich 4
Bayern went into the contest on the back of a chastening 5-0 aggregate UEFA Champions League semi-final defeat to Real Madrid, but Hamburg were unable to capitalise on the visitors' deflated mood.
Mirko Slomka's men needed to win to stand any chance of avoiding a bottom-three finish and they produced some encouraging moments early on, but the Bundesliga champions' quality eventually shone through.
Gotze, who is reportedly unhappy at the Allianz Arena, put Bayern ahead just after the half-hour mark to round off a delightful move and Thomas Muller added their second 10 minutes after half-time, deflecting Gotze's shot in.
Former Borussia Dortmund playmaker Gotze got his second with just over 20 minutes left, before Hakan Calhanoglu pulled on back for Hamburg.
However, any hope of an unlikely comeback from the home side were dashed by Claudio Pizarro, who struck 15 minutes from time to restore Bayern's three-goal cushion before Jerome Boateng was sent off late on following an altercation with Hamburg substitute Kerem Demirbay.
Defeat for Hamburg means they can now only finish the season as high as 16th, which would see them face a relegation play-off.
In the wake of Bayern's humiliating Champions League exit, coach Pep Guardiola defiantly defended his football philosophy, and the German champions showed no sign of abandoning their possession-based game in Hamburg.
But despite Bayern's attempt to monopolise the ball, the hosts created the better chances inside the first 20 minutes.
With 11 minutes played, Ivo Ilicevic pounced on Manuel Neuer's skewed clearance before cleverly flicking the ball over Dante and blasting a half-volley into the sidenetting.
Highly-rated Hamburg midfielder Calhanoglu cut in from the left with intent shortly after, but once again Bayern escaped unscathed as the Turkey international fired wide of the right-hand post.
And Bayern duly capitalised on those let-offs in the 32nd minute, as Gotze combined brilliantly with Arjen Robben inside the penalty area, before coolly slotting under Rene Adler.
Hamburg almost levelled just before the break, but Neuer produced a fine save to deny Rafael van der Vaart's half-volley.
Ominously for Hamburg, Bayern began the second half with renewed focus and after Robben won a corner following a devilish run in towards the right-hand post, they doubled their lead.
Robben delivered the set-piece along the floor to Gotze, and the 21-year-old fired through a crowd of players before Muller flicked it past the helpless Adler.
Gotze got his second of the game in the 69th minute as he brought the ball down nonchalantly in the area before confidently converting a half-volley in from close range.
Hamburg's hopes of a late comeback were given some encouragement as Calhanoglu rifled into the bottom-right corner from long range three minutes later.
But Pizarro's audacious over-head kick, which came just two minutes after he replaced Robben, added gloss to the scoreline for Bayern - whose day was marred slightly when Boateng received his marching orders for going head-to-head with Demirbay after the Hamburg man had tried to win a penalty.