Manchester United confirm Spain midfielder Juan Mata will leave the club on a free transfer when his contract expires this summer.