The decision came a day after Neymar's Brazilian club, Santos, said it had accepted offers from Barcelona and Spanish rival 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 other social media sites.
"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 its 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."
Messi was quoted as saying earlier this week that Neymar would be "a wonderful signing" for Barcelona.
Neymar didn't give any details on the offer he and Santos accepted from Barcelona. The club only said the agreement was for five seasons.
Neymar will play his last match with Santos on Sunday in the team's first match in this year's 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 its 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's 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 Friday that both offers were "similar," but hinted that Neymar already had a "gentleman's agreement" with Barcelona.
Neymar learned the details of the offers late Friday and said he would look at both carefully before deciding. He said he was "very proud" the Spanish powerhouses were interested in him, calling it "one of the happiest moments" of his life.
Brazilian media reported that Real Madrid was willing to pay Santos 35 million euros for Neymar, 7 million euros more than Barcelona. Real Madrid also reportedly offered a bigger salary. Spanish media said the total Barcelona would spend on Neymar could reach about 50 million euros.
Santos officially rejected a 35 million-euro offer for Neymar from Chelsea in 2010 and he eventually re-signed with the club until the 2014 World Cup, with a buyout clause of 65 million euros.
Santos was 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 criticized by some in Europe for his dives and alleged attempts to fake injuries. Pele has repeatedly said that Neymar has the potential to be the best player in the world, even better than Messi, but he is one of the critics who recently said Neymar should try to stop diving so much.
Neymar is also criticized for disappointing performances at decisive moments when he plays for Brazil. His recent lackluster performances with the national team even attracted loud jeers from home fans.
More Sports Headlines
Silvertips’ overage goaltender Lotz heads home to await fate Seahawks' Carroll: Refs missed call but play by Wright was 'smart' Huskies face former coach Sarkisian for first time Caldwell tells Lions not to talk about controversial play Owners offer diverging views on how to return NFL to L.A. Big weekend for Sounders’ Schmid, Barrett Astros beat Yankees 3-0 in American League wild-card game Falcons’ receiver White: ‘I’m not disgruntled’
Our new comment system is not supported in IE 7. Please upgrade your browser here.