Barcelona have agreed a deal with Bayern Munich for Arturo Vidal, announcing the midfielder is set to sign a three-year contract.

The 31-year-old moves for a reported €25 million fee ahead of the final year of his contract, after spending three seasons in Germany. Barcelona said on Friday he would have a medical in the coming days to seal his transfer.

Vidal fills a need for Barca, whose coach, Ernesto Valverde, has desired another midfielder since the club loaned Paulinho back to Guangzhou Evergrande in July after just one season.

Barca had been eyeing Paris Saint-Germain's Adrien Rabiot or Ajax teenager Frenkie de Jong, but instead decided to move for Vidal over concerns they would not be able to complete a deal with their other targets before the transfer deadline.

❗[BREAKING NEWS] Agreement with Bayern Munich for the transfer of @kingarturo23 https://t.co/znSDr6c0VM — FC Barcelona (@FCBarcelona) August 3, 2018

Vidal, a Chile international who was one of the biggest names available this summer, also had been linked to a move to Inter Milan after being deemed surplus to requirements by new Bayern coach Niko Kovac.

He began his career with Colo-Colo before moving to Europe with Bayer Leverkusen in 2007 and then onto Juventus in 2011. He won four straight Serie A titles with Juve prior to joining Bayern.

Vidal scored 22 goals and added 18 assists in 124 competitive games for Bayern, helping them win the Bundesliga all three seasons he spent at the Allianz Arena.

"On behalf of everyone at Bayern, I'd like to thank Arturo very much for three fantastic years," Bayern CEO Karl-Heinz Rummenigge said in a statement. "We won a lot of silverware in that time, and Arturo played a major role in those wins. He was a leader, also in the big game. We could always rely on him."

The signing of Vidal will be Barcelona's fifth of the summer after the additions of Bordeaux's Malcom, Sevilla's Clement Lenglet, Gremio's Arthur and KAS Eupen's Moussa Wague, who completed his move to the Camp Nou earlier on Friday.