Barcelona announced Friday that they had reached an agreement with Bayern Munich to sign Chile midfielder Arturo Vidal in a deal reportedly worth 30 million euros ($35 million).

“FC Barcelona and FC Bayern Munich have reached an agreement for the transfer of player Arturo Vidal,” said Barcelona on their website.

“The agreement is for the next three seasons and is pending the medical examination that the player will undertake over the course of the next few days.

“FC Barcelona will shortly inform everyone about the arrival of the player and the agenda of the presentation ceremony.”

Vidal, 31, was whisked away from Bayern’s pre-season training base on Friday morning with the club’s director of sport Hasan Salihamidzic to finalise the details.

Vidal will reportedly earn around nine million euros per season with the Spanish giants.

His arrival will make up for the surprise departure of Brazilian midfielder Paulinho, who Barcelona loaned to Chinese side Guangzhou Evergrande.

Barcelona had to move fast to sign Vidal as the player had also reportedly sparked interest from Inter Milan following the departure of their French midfielder Adrien Rabiot.

Temperamental on and off the pitch, Vidal’s last season with Bayern was marked by injuries, including one to his knee which he picked up during training and which forced him to undergo surgery in April.

Vidal is the Barcelona’s fourth signing since the end of the last season following the arrival of Brazilian forward Malcolm, Brazilian midfielder Arthur and French defender Clement Lenglet.

The Chilean international joined Bayern Munich in 2015 from Juventus, and won the Bundesliga title in each of his three seasons at the club.

German champions Bayern have been keen to trim their star-studded squad.

Having signed Germany international Leon Goretzka, 23, on a free transfer from Schalke, Bayern chairman Karl-Heinz Rummenigge said earlier this week that they had too many midfielders.