Juan Mata has ended the uncertainty about his future by agreeing a new contract with Manchester United a fortnight before he was due to become a free agent.

Mata’s contract was about to expire at the end of this month but, after 18 months of protracted negotiations, the Spain midfielder has agreed a deal longer than the one-year extension that was initially on offer.

Inter Milan had explored the possibility of signing Mata but their interest came to nothing and it was always Mata’s preference to remain at United. Mata is settled in Manchester, likes the city and owns a restaurant there, Tapeo & Wine, with his father Juan Sr, who is also his agent.

United have tended to favour awarding only one-year extensions to players in their thirties but the club have surprised supporters by giving Mata a longer deal.

Mata has mainly been used as a right-sided forward at United since his £37.1 million move from Chelsea in January 2014, rather than in his preferred No 10 position, and he is likely to be used mainly as a squad player next season with manager Ole Gunnar Solskjaer wanting to play with more pace and mobility in attack.

A popular figure at the club, United believe Mata’s experience and personality in the dressing room is important, particularly at a time when club captain Antonio Valencia and midfielder Ander Herrera have left as free agents.