David Villa looks set to swap Catalonia for the Spanish capital after Barcelona announced it had agreed a deal to sell the striker to Atletico Madrid.

Villa, who is the Spanish national team's all-time leading goalscorer, could cost the 2013 Spanish Cup winners as much as $6.5 million.

"FC Barcelona and Atletico Madrid have reached an agreement in principle for the transfer of David Villa," read a statement from Spanish title holders Barca.

"The deal is set to bring Barca a maximum of €5.1 million, with €2.1m due this season, €2m more if Villa stays at Atletico next year and another million should he be at the Madrid club the season after.

"Barca also reserves the right to 50% of any sell on fee in the future."

Glory on the pitch masks unrest in Brazil 10 photos

Glory on the pitch masks unrest in Brazil10 photos

Glory on the pitch masks unrest in Brazil – Neymar of Brazil celebrates scoring his team's second goal in its 3-0 victory over Spain in the final of the Confederations Cup.

Hide Caption

1 of 10

Glory on the pitch masks unrest in Brazil10 photos

But the build up to the final was marred by clashes between protesters and police in the streets near the Maracana.

Hide Caption

2 of 10

Glory on the pitch masks unrest in Brazil10 photos

The match itself was fully committed, with players from both sides desperate to finish the tournament in style.

Hide Caption

3 of 10

Glory on the pitch masks unrest in Brazil10 photos

The mood on the streets of Rio de Janeiro remained hostile as Brazil and Spain took to the pitch.

Hide Caption

4 of 10

Glory on the pitch masks unrest in Brazil10 photos

Many people in the streets near the stadium were affected by the effects of tear gas.

Hide Caption

5 of 10

Glory on the pitch masks unrest in Brazil10 photos

But inside the stadium, Brazilian fans attempted to put the country's problems aside for 90 minutes.

Hide Caption

6 of 10

Glory on the pitch masks unrest in Brazil10 photos

Hulk of Brazil and Sergio Ramos of Spain compete for the ball in a match the hosts dominated.

Hide Caption

7 of 10

Glory on the pitch masks unrest in Brazil10 photos

Football amid fury: Protests rage as Brazil lifts Confederations Cup – In the end, two goals from Fred (pictured) and Neymar gave Brazil an emphatic win over the World and European champions.

Hide Caption

8 of 10

Glory on the pitch masks unrest in Brazil10 photos

Brazil players Dante, left, and Dani Alves, in a wig, celebrate with their winner's medals.