Barcelona and Gremio have officially announced an agreement on a purchase option for the Copa Libertadores winner Arthur Melo for up to €39m.

Barcelona, who announced the news on their ​club website, can take up the option from July 2018 for an initial fee of €30m, with €9m in 'variable amounts'.

"FC Barcelona and the Brazilian club Gremio de Porto Alegre have reached an agreement on a purchase option for the player Arthur Henrique Ramos de Oliveira Melo, whereas FC Barcelona may exercise this right on the player's federative rights during July of 2018," the statement read.

Lanus v Gremio - Copa CONMEBOL Libertadores 2017

La Blaugrana's courtship of 21-year-old midfielder Arthur has been one of the worst kept secrets in football, with the the young Brazilian widely expected to make the move to Catalonia for some time.

Officials from the club and the player's agents travelled to Barcelona to finalise negotiations last week, ​but the move appeared to hit a snag with reports suggesting that the club representatives were set to walk away from the deal and return Brazil, after disagreements over payment structures.

However, while the financial side of the deal has been wrapped up, there is no guarantee that Barcelona will bring the rising star in immediately due to league limitations on non-EU players.

Barcelona do not, as it stands, have a place available for Arthur with Yerry Mina, Philippe Coutinho and Paulinho taking up the three slots.

Lanus v Gremio - Copa CONMEBOL Libertadores 2017

Coutinho is reportedly in the process of applying for Portuguese citizenship, through his wife, but there is no word on how long this could take.

Arthur is a Brazil Under-20 international and has played 51 times for Gremio since breaking into the senior team in 2016. He has won the Copa Liberadores title, as well as the Copa do Brasil and Recopa Sudamericana and has been tipped for a call up to his country's senior team this summer for the World Cup in Russia.