Liverpool have agreed a €40.9m deal to sell Sadio Mane to Bayern Munich.
The Bundesliga champions will pay €32m up front, with a further €5.9m due when the 30-year-old meets a specified appearance clause and an additional €3m based on individual and team achievements.
Mane, who joined Liverpool from Southampton in a deal eventually worth €39m, was in the final year of his contract and had expressed his desire to leave.
Bayern believed they could secure the Senegal forward on the cheap with an opening offer of €25m plus €5m in add-ons, based on what Liverpool considered unrealistic individual and team achievements.
However, with the arrival of 22-year-old Benfica striker Darwin Nunez in a potential club-record €100m deal the club were willing to allow Mane to go providing Bayern came up with a figure which closer suited their €46m valuation.
After Bayern officials flew to Merseyside for a meeting on Friday a compromise was made and an agreement was reached.
Mane, who is believed to have agreed a three-year contract with the German club, is a likely replacement for Robert Lewandowski who has expressed a desire to leave.
Mane scored 120 goals in 269 appearances across six seasons at Anfield and won the Premier League, Champions League, FIFA Club World Cup, European Super Cup, FA Cup and League Cup.

Meanwhile, Porto have confirmed the deal to sell midfielder Fabio Vieira to Arsenal for €40m.
The uncapped 22-year-old will now become Arsenal's third summer arrival, after goalkeeper Matt Turner and Brazilian forward Marquinhos.
Vieira won the player of the tournament award at last year's European Under-21 Championship with Portugal.
Vieira will add further creative talent to Arsenal's ranks, with the highly-rated midfielder having laid on a league-high 14 assists in the 2021-22 Primera Liga campaign.
"The club informs the market that it has reached an agreement with Arsenal FC for the signing, on a permanent basis, of Fabio Vieira for the amount of €40m," read a Porto statement.
Arsenal are yet to announce the signing, but Vieira was understood to have been in north London on Thursday carrying out a medical with the Gunners.
Mikel Arteta is expected to continue to push for further summer recruits at Arsenal, with Manchester City's Gabriel Jesus heavily linked to an Emirates Stadium switch and Leicester's Youri Tielemans another target.
Leeds have completed their third summer signing with the arrival of Spanish midfielder Marc Roca from Bayern Munich.
Roca, 25, a former Spain Under-21 international, has joined on a four-year deal for an undisclosed fee, reported to be £10.4million.
A Leeds statement said: "Leeds United can today announce Marc Roca will join the club on July 1 2022 after an agreement was reached with FC Bayern Munich.
"The 25-year-old will join on a four-year-contract running until the summer of 2026, for an undisclosed fee."
Leeds' first two summer signings, Brendan Aaronson and Rasmus Kristensen, both joined from head coach Jesse Marsch's former club Red Bull Salzburg for undisclosed fees, reported to be #24.7m and around £10m respectively

Tottenham have completed the signing of Yves Bissouma from Brighton on a four-year deal.
The midfielder moves to Spurs for a €29m fee which could increase due to add-ons.
Bissouma becomes the third summer signing made since Antonio Conte's side secured Champions League football at the end of last season.
Listen to the RTÉ Soccer podcast on Apple Podcasts, Spotify or wherever you get your podcasts.
We need your consent to load this YouTube contentWe use YouTube to manage extra content that can set cookies on your device and collect data about your activity. Please review their details and accept them to load the content.Manage Preferences