Mata, 36, then spent nine years at United, where he won the Europa League, FA Cup, League Cup and Community Shield, scoring 51 goals in 285 appearances.
He then had short stints at Galatasaray and Vissel Kobe, winning the Super Lig and J1 League respectively.
“I’m really excited to join the Western Sydney Wanderers, the only Australian team to ever win the Asian Champions League, and I cannot wait to arrive and train with the team to prepare for the season ahead,” Mata said in a statement.
“I’m feeling grateful and excited for this new adventure, and looking forward to trying to win another championship in a different league.”
There will clearly be queries over Mata’s fitness. The 36-year-old playmaker most recently played competitively off the bench for Vissel Kobe in September 2023.
But Wanderers coach Alen Stajcic relished adding Mata’s class to his squad.
“The addition of Juan to our club and team is priceless,” Stajcic said.
“He is one of the most respected, gifted and awarded players of a generation and brings not only football talent and success rarely seen in Australian club football, but also a humility to share his experiences and insights.
“Juan will help our team perform on the field but, even more critically, he will be an important figure in turbo-charging the growth and development of our youthful squad.
“It’s a great day for our football club and I am sure all Wanderers fans will be excited to see what this team can deliver now.”