Borussia Dortmund have confirmed that captain Mats Hummels has agreed to return to Bayern Munich this summer.
Hummels, whose Dortmund contract was due to expire in 2017, has not yet passed a medical with Bayern but the details of the transfer have been agreed.
Mats Hummels verlässt Borussia Dortmund im Sommer. https://t.co/HLS5wTjng5
- Borussia Dortmund (@BVB) May 10, 2016
No details of the fee were announced but Dortmund were reported to be demanding around €35 million for the Germany centre-back, which would represent the highest ever transfer fee for a Bundesliga player entering the final 12 months of a contract.
Dortmund had been obliged to issue a statement last month confirming that the 27-year-old had indicated that he wanted to return to Bayern, where he had started his career before moving to the Westfalenstadion, initially on loan, in 2008.
Following that announcement, Hummels -- who is set to captain Dortmund in the DFB Pokal final against Bayern on May 21 -- had been booed by home fans at the Westfalenstadion.
TRANSFER COMPLETE! #FCBayern have also signed @matshummels, with the centre back agreeing a contract until 2021 too! pic.twitter.com/YShoT9dlL9
- FC Bayern English (@FCBayernEN) May 10, 2016
There had been reports in Germany that Hummels had since changed his mind and was ready to sign a contract extension with BVB, but chief executive Hans-Joachim Watzke told Sky at the weekend: "The ball is in his court."
On Tuesday, Watzke said in a statement on Dortmund's official website: "Mats Hummels has decided after long, intense reflections to return to his native Munich, eight-and-a-half years after his move to BVB.
"I want to stress that he has always acted openly and fairly toward us. Mats won two Bundesliga titles and the 2012 double. He reached the 2013 Champions League final with us and won the 2014 World Cup as a Dortmund player.
"We respect Mats' decision and our wish for him and for BVB is that he gets the recognition he deserves in his last weeks as a 'black and yellow' and leaves Dortmund with the DFB Pokal in his hands."
Meanwhile, the sale of Hummels is set to turn around annual losses standing at almost €21m.
Hummels added: "It was not an easy decision for me after eight-and-a-half years at BVB. I was always proud, and I still am, to wear the BVB jersey and be part of this extraordinary team.
"Before I return to my hometown in the summer, we all have one big common goal: To again bring the DFB Pokal to Dortmund and celebrate a football party with the BVB fans. I will give it my all for that, just like my teammates. I would like to dearly thank my teammates, the employees and the fans for this long and wonderful time in black and yellow."
Hummels is set to become the third BVB player to join Bayern since the summer of 2013, when Mario Gotze activated a release clause in his contract. In 2014, Robert Lewandowski moved to the Allianz Arena on a free transfer.
Bayern CEO Karl-Heinz Rummenigge told his club's official website: "We are delighted that Mats Hummels has opted for FC Bayern. Mats is one of the world's best centre-backs, and we can once again increase the quality of our team with his signing."
Bayern, who confirmed the signing of Renato Sanches from Benfica earlier on Tuesday, could now seek to offload centre-back Medhi Benatia, who has struggled to live up to expectations since his 2014 switch from Roma.