Claudio Pizarro struck twice in as many minutes to secure Werder Bremen a victory that almost certainly ends any relegation fears at St Pauli.
St Pauli had led through Fin Bartels's 29th-minute opener but Bremen were level on 50 minutes thanks to a Markus Thorandt own goal.
That set the stage for former Bayern Munich striker Pizarro to grab the points with his goal after 73 and 74 minutes.
Werder extended their undefeated streak to eight matches to move to 38 points for 11th place - nine points clear of the drop zone.
St Pauli have not won in nine matches and remain second-bottom and five points from safety.
Werder were the stronger team in the early going and nearly took the lead after 13 minutes as Pizarro blasted Sandro Wagner's cross from the right side off the near post.
But it was St Pauli who jumped ahead after 29 minutes as Ralph Gunesch beat the offside trap with his pass to Bartels, who blasted past Werder goalkeeper Tim Wiese from 10 yards out.
Bremen levelled five minutes after the break as Philipp Bargfrede streaked down the right flank and crossed into the middle where Thorandt deflected the ball into his own net.
Wiese made a great save to deny Gerald Asamoah in a one-on-one situation in the 52nd minute.
And then Pizarro took over with two goals within two minutes.
Bremen went ahead after 73 minutes as Pizarro headed home Torsten Frings' corner.
The Peruvian striker doubled his tally in the 74th minute as he ran onto a through ball from Marko Marin, and poked past St Pauli keeper Benedikt Pliquett before running onto the loose ball to score.