Barcelona agree to sell Villa to Atletico Madrid

The 31-year-old, Spain's all-time leading scorer, will move for a fee of up to 5.1 million euros with Barca reserving 50 percent of the rights over any future transfer.

Atletico will pay 2.1 million euros this season, a further 2 million if the player continues to play at the Calderon in the 2014/15 season, and another one million if he extends his contract to 2016, Barca said in a statement.

"The agreement and the signing of Villa as a new player at Atletico will be formalised after the player has taken a medical," Atletico said on their Twitter feed.

The arrival of young Brazil forward Neymar at the Nou Camp had threatened to push Villa even further out of the reckoning in Tito Vilanova's side, after a season where he struggled to hold down a regular first team place.

With the World Cup finals looming in Brazil next year, Villa will be keen to make sure he is playing regular football at the highest level.

The signing is something of a coup for King's Cup winners Atletico, who were looking for a replacement for Colombia striker Radamel Falcao after he left to join big-spending Monaco.

Atletico finished third in La Liga last season and qualified for the Champions League groups stage, but the cash-strapped club looked to be at the back of the queue as Villa was linked with interest from clubs in England.

Villa has played for Sporting Gijon, Real Zaragoza and Valencia, who he left for Barcelona in 2010 for 40 million euros.

He scored 48 goals in 119 games with the Catalans, including one in the Champions League final against Manchester United in 2011, and helped them win two La Liga titles.

At international level, he helped Spain win Euro 2008 and the World Cup in 2010, finishing as the side's top scorer at both tournaments.

He missed Euro 2012 as he recovered from a broken leg suffered in the Club World Cup at the end of 2011, but remains his country's all-time leading scorer with 56 goals from 92 appearances.

One of his first official games for Atletico could be against Barcelona in the Spanish Super Cup next month.