The 21-year-old will sign a five-year contract, the club said, with the player confirming he will sign his contract on Monday.
A Barcelona statement read: "FC Barcelona and Santos have agreed to terms for Neymar da Silva Santos Junior. The Brazilian forward will don the Blaugrana strip for the next five seasons. The 21-year old is one of the most promising footballers on the planet."
Neymar had been considering his future after his club Santos revealed on Saturday that they had accepted two offers for their star player, with Barca confirmed as one of the bidders and Real Madrid widely assumed to be the other.
Neymar has confirmed his decision on Sunday, writing on Instagram: "I'm here with friends and family and they have helped me to write a few things here. I'm not going to hold out until Monday. My family and friends already know my decision.
"On Monday I will sign a contract with Barcelona."
The 21-year-old's contract at Santos was due to expire at the end of next season and some reports had suggested an agreement with Barcelona was reached as much as a year ago.
Now the move has been confirmed.
Neymar wrote: "I want to thank the fans of Santos for these incredible nine years. My feeling for the club and the fans will never change. It is eternal!
"Only a club like Santos FC could give me everything I have experienced on and off the field. I thank the wonderful fans who supported me even in the most difficult moments.
"Titles, goals, dribbling, celebrations and songs that fans created for me will be forever in my heart..."
Neymar will say goodbye to the Santos fans at Sunday's season-opening game against Flamengo.
"I made sure I could play the match tomorrow in Brasilia," he said. "I want to have the opportunity to once again take the field and hear the crowd scream my name ...
"It is a strange time for me, sad (farewell) and happy (new challenge). May God bless me in my choices ... And I'm always a Santos fan!"
In a statement, Santos said they had made every effort to keep hold of the player.
It read: "The management committee of Santos FC announces that it has received notification from the athlete Neymar Jr advising that he has decided to accept the proposal of Barcelona. The transfer of playmaker to the Spanish team will be sealed in the coming days.
"After refusing a offers of many millions for Neymar Jr since mid-2010, and implemented a career plan that allowed his historic stay in Brazil for several years, bucking the trend of Brazilian football to quickly sell its greatest talents, Santos FC finally agreed to sell.
"Every effort was made to keep him in Brazil as long as possible, even offering to renew the current contract, which ended in July 2014. At this time, however, it was not possible to compete with the terms offered from abroad, which affected the decision of the player to review his professional life.
"Due to the confidentiality agreement, and by mutual agreement, the terms of the transfer will not be disclosed by any of the parties."
Neymar is a superstar in Brazil, and his departure will be a big blow to fans of Santos, who had hoped he might stay until after next year's World Cup in the country.
With Neymar, who made his debut as a 17-year-old in 2009, Santos have enjoyed their greatest period of success since Pele was playing for the club, winning three straight Campeonato Paulista titles and the Copa do Brasil.
The crowning glory came in 2011 when the club won the Copa Libertadores for the first time since 1963 and Neymar was named the South American Footballer of the Year as well as winning the Puskas Award for the world's best goal.
The statement from Santos concluded: "More than an idol, Neymar Jr became a myth not only for Santos, but for Brazilians and football fans around the world.
"The club says goodbye for now to its playmaker, wishing you much success in your new journey, certain that the Vila Belmiro (stadium) will continue being your second home."