Spanish federation (RFEF) president Luis Rubiales and his CBF counterpart, Ednaldo Rodrigues, said they would reinforce their commitment against violence in football with the match, part of a friendly series that will see Brazil play against one other UEFA team.
The RFEF and the CBF said in a joint statement that they hope the match can "reinforce the commitment of both entities against violence in football and to intensify the already existing good relations" between the two countries with a venue in Spain as yet to be determined.
"This action, in collaboration with my friend Luis Rubiales, will be important to further reinforce the need to fight vehemently against racism in all corners of the planet," Rodrigues said in a statement.
The Brazilian has been subjected to insults since he came to play in Spain five years ago.
A match at Mestalla between Real Madrid and Valencia earlier this season was stopped during the second half after the Brazil international identified a fan in the crowd behind the Valencia goal as having racially abused him.
In social media posts after that game, Vinícius said that "racism is normal in LaLiga" and claimed that "in Brazil, Spain is known as a country of racists."
LaLiga has filed complaints to authorities for racist insults or chants against Vinicius, with some of them being shelved by prosecutors.
Rubiales has publicly admitted that Spain has a problem with racism.
Spain last played against Brazil at the 2013 Confederations Cup and this would be the 10th time the two countries meet.
They are 5-2-2 in those previous nine meetings.
UEFA had previously floated a measure for CONMEBOL teams to join 2024-25 UEFA Nations League play, but the plan never materialised.
The CBF announced that Brazil will play friendlies against Guinea on June 17 and Senegal, three days later, also as a part of an anti-racism campaign.
Information from The Associated Press and Reuters was used in this report.