Neymar will play for Brazil at the Rio de Janeiro Olympics but will skip the Copa America, Barcelona said on Wednesday.

The news was announced after the 8-0 La Liga win over Deportivo, with Neymar netting one of the goals to end the forward's five-game scoreless run.

Neymar had said he wanted to play in both tournaments and the Brazilian soccer confederation had asked for his release, but Barcelona did not want to lose the striker for so long and feared that his participation in both events could affect his preparations for next season.

Neymar celebrates with team-mate Lionel Messi after scoring in the 8-0 win at Deportivo

The confederation and the club had been in talks for several months before finally reaching a deal.

"FC Barcelona expresses its gratitude to the Brazilian Football Confederation and its president Marco Polo del Nero for accepting the Club's proposal for Neymar Jr to only play at the Olympic Games in Rio de Janeiro this summer, and not at the Copa America in the United States," the Barcelona said in a statement.

Clubs are not obliged by FIFA to release players for the Olympics, but had to do so for the Copa America Centenario in the United States, but a deal has been struck to ensure Neymar is exempt.

Barcelona want Neymar as fresh as possible for the start of the season

The Olympics will be played from August 3-21, while the Copa America runs from June 3-26.

The Olympic tournament is played with U23 squads and only three over-age players are allowed in each team. Neymar, 24, will be one of the three overage players in the squad coached by Dunga.

Brazil are in Group A at the Olympic tournament in Rio, along with South Africa, Iraq and Denmark, and open against South Africa on August 4 in Brasilia.