Juan Mata has reached an agreement on a new contract tying him to Manchester United for the next three years. The deal will run until the Spaniard is 34, with the intention of him remaining at the club after he retires as a player.

Mata’s current contract, which is worth £140,000 a week, expires in just over two weeks’ time, on 30 June. The Spain midfielder had attracted interest from Barcelona and, although talks with United have been going on for months, he had initially failed to reach an agreement on his salary and the duration of the deal and appeared set to walk away without renewing. Herrera and Antonio Valencia had already departed in similar circumstances as their existing deals concluded.

Mata’s salary will not change significantly but the three-year contract contrasts well with the one year offered initially. He played 32 times last season, scoring six goals. He was taken off at half-time in the Champions League against Paris Saint-Germain. Despite playing an increasingly limited role, Ole Gunnar Solskjær considers him a useful squad player.

If Mata sees out his contract until 2022, he would have been at the club for eight years since signing for £37.5m under David Moyes. He has scored 47 goals and provided 39 assists in 238 games at the club.