Bayern Munich's Douglas Costa has agreed terms with Juventus, dealing a blow to Barcelona and Liverpool.

The Brazilian winger has found his game time limited this past season under Carlo Ancelotti and as a result, has been on the radar of a host of clubs.

It appeared that Barcelona and Liverpool would be the front-runners for the 26-year-old's signature with both clubs desperately in need of attacking reinforcements and the former ready to offer €30m (£26.2m, $33.8m).

However, according to the Gazzetta dello Sport, Costa has agreed terms with Champions League finalists Juventus for a €5m (£4.4m, $5.6m) per-year salary with bonuses after meeting general manager Beppe Marotta.

Only an agreement with Bayern remains and while the Bundesliga champions value Costa at €50m (£44m, $56m), Juventus are ready to open negotiations at €35m (£30.8m, $39m), hoping that the two clubs' good relations help facilitate a transfer.

Former manager of Costa during his Shakhtar days, Mircea Lucescu has spoken out on the potential move, stating that it is a good deal for both player and club.

"He's proven that he is suited to a big club and he's gained a lot of experience, also in the Champions League and in the national team," Lucescu said, as quoted on ESPN. "This is fundamental because experience improves you, but you only gain it over time."

"Over the years at Shakhtar, we taught him to make himself at the service of the group. It would be a great choice [for Juve]. If the deal goes through, I would be delighted for him. I am always happy to see a player I signed improve and join a big club."

Costa joined Bayern Munich from Shakhtar Donetsk in 2015 for a fee of £21m (£18.5m, $23.5m)and enjoyed a fine debut season under Pep Guardiola, winning the Bundesliga as he contributed with four goals and 10 assists in 27 league games.