Javi Martinez will leave Bayern Munich at the end of this season, the Bundesliga champions have confirmed.

Martinez joined Bayern from Athletic Bilbao in 2012 and straight away went about repaying what was then a club-record outlay of €40million, becoming a key member of their treble-winning squad under Jupp Heynckes.

Should Bayern complete the formalities of winning a ninth consecutive Bundesliga title – one that will in all probability be wrapped up this coming weekend – defensive midfielder Martinez will become the only player in Bundesliga history to have won as many as nine titles without failing to win the championship in any season.

Thomas Muller, Manuel Neuer, David Alaba and Jerome Boateng have also been part of all nine of those successive successes, but the latter two will join Martinez and head coach Hansi Flick in leaving Bayern at the end of the campaign as a period of transition under new boss Julian Nagelsmann awaits.

Despite frequently suffering injury setbacks during his time at the Allianz Arena, Martinez has made 266 appearances for Bayern, scoring 14 goals and supplying 11 assists.

"I'm very proud and happy to have been part of the FC Bayern family for nine years. I’d like to thank this great club and especially our fans – you have made Munich my home," the 32-year-old told Bayern's official website.

"I'll never forget these nine years. From the very first day, I felt the 'Mia san mia' and the special nature of FC Bayern.

"I lived for this club, always gave everything for it, and am very happy about the many titles we won together. FC Bayern and its fans will forever be in my heart."

Martinez added a second Champions League to his Bayern haul last season, when Kingsley Coman scored the only goal to down Paris Saint-Germain in Lisbon.

He won a pair of Club World Cups and UEFA Super Cups on the back of those triumphs in Europe's top competition, scoring vital goals in each of the latter games – a last-gasp leveller against Chelsea in 2013 to force a penalty shoot-out and an extra-time winner versus Sevilla last year.

He also won five DFB-Pokals and four DFL-Supercups.

"Javi was a very important player for FC Bayern over nine years, a defining player not just on the pitch but also in the dressing room and all around the club," said sporting director Hasan Salihamidzic.

"His track record is almost unparalleled, especially in the big games where he was one who made the difference, starting with the 2013 Champions League final.

"He was versatile, put himself at the service of the team and always gave his all. Javi has his permanent place in the FC Bayern family and will keep it.”