Sadio Mane scored 120 goals in all competitions for Liverpool
The Reds will get a fixed 32m euros (£27.4m) with an additional 6m euros based on appearances and 3m euros based on individual and team achievements.
Liverpool turned down two bids from Bayern before the two clubs settled on a move for the 30-year-old, whose deal with the Reds ran until next summer.
He joined Liverpool for £31m plus £2.5m in add-ons from Southampton in 2016.
Since then, Mane scored 90 Premier League goals for the Anfield club and finished last season with 23 goals in all competitions.
News of his departure follows Tuesday's signing of Uruguay forward Darwin Nunez from Benfica for an initial £64m.
Alongside fellow forwards Mohamed Salah and Roberto Firmino, who are both 30, Mane has been integral to Liverpool's success in recent years.
The trio helped the club win the Champions League in 2019 and then end a 30-year wait for the league title in the following season.
This has also been an exceptional year for Mane, who won the Africa Cup of Nations with Senegal before helping Liverpool win the Carabao Cup and FA Cup and finish runners-up in the Premier League and Champions League.
Mane is expected to replace Robert Lewandowski at Bayern, with the Poland international set to lave the German club having been linked with a move to Spanish giants Barcelona.
-- Courtesy of BBC Sport