Martinez was Bayern Munich’s most expensive signing ever when he joined from Athletic Bilbao for €40m in the summer of 2012.
The former Spain international has enjoyed a trophy-laden career in Bavaria, winning two UEFA Champions League trophies, eight Bundesliga titles and five DFB-Pokals among other honours.
Martinez’s contract with Bayern expires this summer and both parties have decided to go their separate ways.
“I’m very proud and happy to have been part of the FC Bayern family for nine years," the Spain midfielder told the club's official website. "I’d like to thank this great club and especially our fans – you have made Munich my home!
"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. Muchas gracias, dankeschön, servus – see you again!”
Bayern CEO Karl-Heinz Rummenigge added: "Javi gave our team great quality in terms of play and has always been an excellent personal fit.
"May I thank Javi for a tremendously enjoyable and successful time. Take care, Javi. You’ll always be an important part of the FC Bayern family.”
Martinez is the latest high profile name who will leave Bayern this summer, with David Alaba, Jerome Boateng and manager Hansi Flick all leaving at the end of the season.