The 35-year-old has featured 27 times for Bayern this campaign, including playing all 180 minutes in their 10-2 aggregate Champions League last 16 triumph over Arsenal.
There had been reports earlier in 2016-17 that Alonso was considering hanging up his boots – with Philipp Lahm also catching the football world by surprise – but nothing official until now.
Alonso tweeted on Thursday morning: “Lived it. Loved it. Farewell beautiful game.”
Afterwards, he told Bayern’s website that he didn’t want to wait until his legs had gone and he was struggling to match the performance consistency he;s shown throughout his career.
“It wasn’t an easy decision to make, but I believe it’s the right time,” he said. “I always thought it would be better to quit sooner rather than later. I still feel good, but I believe this is the right moment.
“I wanted to end my career still at the highest level, and Bayern is the highest level. I’m incredibly proud and happy to play for FC Bayern and to be a part of this family.”
The Bundesliga club’s chairman Karl-Heinz Rummenigge was quick to shower praise on the Spaniard, who has been with the club since August 2014.
“Bayern would like to thank a great player and a man who has played the Bayern way on and off the pitch excellently,” he said.
“Xabi Alonso is one of the greats of world football. He has won everything in his career. He is also an outstanding personality, a gentleman of football.”
Alonso’s career started at Real Sociedad in 1999 before Premier League giants Liverpool snapped him up four years later.
He became an iconic midfielder at Anfield, winning the Champions League with the club in his first season and three other trophies.
In 2009, five years after joining, he left for Real Madrid in a deal estimated to be worth £30 million. He won five titles in five years at the Santiago Bernabeu, including one Champions League final triumph.
He won the World Cup with Spain in 2010 in addition to being a champion at the 2008 and 2012 European Championships.