Mata, 31, had been free to talk to other clubs with his previous contract expiring this month after protracted negotiations between the two parties.
However, having already seen Ander Herrera and club captain Antonio Valencia leave Old Trafford on free transfers this summer, United were keen stop Mata from following suit.
"It is a real honour to continue to represent this amazing club and our incredible fans. I have been at Manchester United for five years and I am proud to call Old Trafford my home," said Mata, who joined from Chelsea in 2014 for a fee of £37 million ($46 million).
"I am looking forward to working with Ole (Gunnar Solskjaer) and his fantastic coaching staff; the vision that they have for the club is truly exciting and I am so happy that I will be a part of that."
In his five years at United, Mata has scored 45 goals in 218 appearances and won the Europa League, FA Cup and League Cup.
Solskjaer has a major rebuild on his hands after United finished sixth in the Premier League last season to miss out on Champions League qualification.
"Juan is the ultimate professional and one of the most intelligent players I have worked with," said Solskjaer.
"He is a great example to our younger players in his approach. He understands what it means to be a Manchester United player and has embraced everything about this great club."
United have only made one signing so far this window in securing the services of Wales winger Daniel James from Swansea.