He made 285 appearances for the club, scoring 51 goals, and won the FA Cup, League Cup and Europa League.
United said in a statement: "Thank you for dedicating eight years of your career to United, Juan. Everyone at the club wishes you all the best for the future."
In a video message recorded on the Old Trafford pitch, Mata said: "I wanted to say thank you very much to all of you for your support over the years and especially during the difficult times that we lived together. I will never forget you, thank you very much. All the best, from the bottom of my heart and goodbye."
Nemanja Matic said in April he would end his five-year stay at United this summer, leaving new manager Erik ten Hag with several key positions to fill ahead of his first season in charge.
United have been linked with Barcelona midfielder Frenkie de Jong but they suffered a setback in their pursuit with the player telling ESPN he would prefer to stay at Camp Nou.