Neymar said he will be joining Barcelona after the Confederations Cup, the latest addition to a star-filled roster that already includes four-time Fifa Player of the Year Lionel Messi, Xavi Hernandez and Andres Iniesta.
The decision came a day after Neymar's Brazilian club Santos said it had accepted offers from Barcelona and Real Madrid, and that it was up to him to pick where he wanted to play.
The 21-year-old striker made the announcement on Twitter and Instagram. "I wouldn't be able to wait until Monday. My friends and my family already know of my decision," he wrote. "On Monday, I will sign a contract with Barcelona."
Barcelona confirmed the deal on their own Twitter account.
"FC Barcelona have reached an agreement with Santos for Neymar," the club said. "The Brazilian player will join FC Barcelona for the next five seasons."
The club offered more praise on its website, calling him "one of the most promising footballers on the planet".
Messi was quoted as saying this week that Neymar would be "a wonderful signing" for Barca.
Neymar didn't give any details on the offer he and Santos accepted from Barcelona. He was to play his last game overnight with Santos in the team's opener in the Brazilian league.
"I want to thank Santos fans for these nine incredible years. My feelings for the club and the fans will never change," he said. "I made it sure that I play [this last match] so I can have the opportunity to once again enter the field wearing the team's jersey and to hear the fans chant my name."
Neymar led Santos to their greatest run since Pele stopped playing for the club in the 1970s, helping the team win the 2010 Brazilian Cup, the 2011 Copa Libertadores and three straight Sao Paulo state championships. He is the club's leading scorer in the post-Pele era with 138 goals in 229 matches. He is also considered the national team's key player in the upcoming Confederations Cup and World Cup, which Brazil hosts next year.
Neymar will join Barcelona after the Confederations Cup, as the transfer window in Europe opens in July.
The signing ends years of speculation about which team would be the first to persuade the Brazilian sensation to make the move to Europe. Neymar has never hidden his desire to one day play for Barcelona, but this week Real Madrid also became a front runner to sign him.
Santos vice-president Odilio Rodrigues said both offers were "similar", but hinted that Neymar already had a "gentleman's agreement" with Barcelona.
Neymar said he was "very proud" the Spanish powerhouses were interested in him, calling it "one of the happiest moments" of his life.
Santos officially rejected an offer for Neymar from Chelsea in 2010, and he eventually re-signed with the Brazilian club until the World Cup, with a buyout clause.
Santos were trying to sell Neymar as quickly as possible because in six months the player would be allowed to sign a pre-contract with any other club, and the Brazilian team would not get anything in return.
Neymar is an idol on the field and a celebrity off it in Brazil. He appears in dozens of television commercials and his image is plastered on billboards across the country, making him by far the best paid athlete in Brazil.
This week, he topped the list of most marketable athletes in the world in a report published by SportsPro magazine, finishing ahead of Messi and golfer Rory McIlroy. But he is also criticised by some in Europe for allegedly diving and faking injury.
Pele has repeatedly said that Neymar has the potential to be the best player in the world, but he also recently said Neymar should try to stop diving so much.
Neymar is also criticised for disappointing performances at decisive moments when he plays for Brazil. His recent lacklustre performances with the national team even attracted loud jeers.