The Spaniard has signed a one-year extension that will keep him at Old Trafford until 2022.
Mata's contract expired on Wednesday night but after agreeing fresh terms, the 33-year-old will be part of Ole Gunnar Solskjaer's squad for next season.
In January 2022 he will celebrate eight years at United following his move from Chelsea in 2014.
Mata has made 273 appearances for the club, scoring 51 goals. He was limited to just 18 appearances in all competitions last season after missing part of the campaign because of personal circumstances.
Sources told ESPN Mata's preference was to stay at United as long as he felt he had a part to play on the pitch.
Solskjaer was keen for the World Cup winner to stay to provide experience to a young squad which will also include 21-year-old Jadon Sancho next season after a £72.9 million fee was agreed with Borussia Dortmund.
Sancho will join a forward line which already includes Marcus Rashford, Mason Greenwood, Anthony Martial, Dan James and Edinson Cavani. Jesse Lingard, who spent the second half of last season on loan at West Ham United, is also expected back for the start of preseason training.
The 35-year-old has put pen to paper on a two-year contract and returns to Old Trafford after previously spending 13 years at the club.
"For me to have the opportunity to come back after spending 13 great years here as a kid, it's an incredible feeling and I'm really, really excited to get started," he told the club's official website.
"I'm just seeing it as a fantastic opportunity as I still feel I've got an awful lot to give and I've got the bit between my teeth.
"I'm looking forward to hitting the ground running. I feel in great shape and I'm looking forward to coming in to compete with the other goalkeepers."