Pep Guardiola's men twice fell behind at the Allianz Arena before the Peruvian bagged a double in just four minutes to send the hosts on their way to a morale-boosting win
Seeking to overturn a 1-0 first-leg deficit when they meet Real Madrid in the Champions League semi-finals on Tuesday, the hosts warmed up in style with a fine display of attacking verve in the Bundesliga.
But the final score did not tell the full story of a game that, for 45 minutes at least, Werder competed well in, with a second-half masterclass and the contribution of former Werder striker Claudio Pizarro ultimately proving decisive.
The visitors took an unexpected early lead when Theodor Gebre Selassie was on hand to round off a well-worked counterattack, before Franck Ribery levelled 10 minutes later.
Despite the hosts creating a number of chances, Aaron Hunt restored Werder's advantage just before the break by finishing another breakaway.
It was a different story after the restart, though, as Bayern responded with three goals in eight minutes - Pizarro marking his return to the side with a brace, before Bastian Schweinsteiger's towering header made it four.
Arjen Robben then came off the bench to add a fifth with a trademark finish to give Bayern a much-needed boost.
Coach Pep Guardiola clearly had one eye on Tuesday’s clash with Madrid, making five changes to the side that had lost in Spain.
There was an emotional start to proceedings at the Allianz Arena as players and fans observed a minute's silence to pay their respects to former Barcelona boss, and Guardiola's assistant at Camp Nou, Tito Vilanova, who died on Friday after a long battle with throat cancer.
Despite the hosts seeing plenty of possession in the opening exchanges, it was Werder who took the lead after 10 minutes when a sweeping counter-attack saw Cedric Makiadi release Gebre Selassie, who burst into the area to score.
Much had been made about the form of Ribery before the game, with Guardiola insisting that the Frenchman was on the verge of recapturing the kind of displays that saw him in the running for Ballon d’Or.
The Spaniard's faith was rewarded with the equaliser after 20 minutes, when a perfectly weighted ball from Pizarro found the onrushing Ribery in the box, who applied a calm finish.
Pizarro almost troubled his former employers again 10 minutes before half-time, but his chip was wayward.
And Bayern's failure to find a second goal was punished three minutes later, when Franco Di Santo played in Hunt, who passed the ball home.
However, a disappointing first half for Bayern was quickly forgotten after the break as Pizarro made amends for his earlier wastefulness by latching onto Thomas Muller's flick and poking the ball in at the far post.
The Peruvian decided not to celebrate out of respect to his former club, but he increased their woes four minutes later when Ribery released David Alaba, who squared for the veteran striker to finish.
Having finally found their rhythm, Bayern were relentless and would have had a third through Javi Martinez just before the hour were it not for a smart save from Wolf.
But just two minutes later the visiting goalkeeper was picking the ball out of the net for a fourth time, as Schweinsteiger headed home from substitute Philipp Lahm's cross.
There was still time for Bayern to add a fifth 16 minutes from time when Robben came off the bench to fire in a low drive.
That compounded a difficult afternoon for Robin Dutt's men, who missed a golden opportunity to confirm their Bundesliga status, while Bayern readied themselves for a bigger test against Madrid.