Barca will be investigated for alleged misappropriation of funds in the £48.6m (57m euros) deal with Santos.
The signing of Neymar has been correct and his signing has caused despair and envy in some of our adversaries
Rosell, speaking at a news conference after a Barca board meeting, insisted he had "acted correctly".
Vice-president Josep Maria Bartomeu now takes over from the 49-year-old Rosell, who came to power in 2010.
Rosell's future has been a real source of concern ever since a Spanish national court judge accepted a lawsuit this week from Barcelona club member Jordi Cases, who alleged that the amount paid for Neymar was more than the reported fee.
Rosell maintains the accusation is "unfair and reckless".
He added: "For some time, my family and myself have suffered threats and attacks in silence. These threats and attacks have made me wonder if being president means having to jeopardise my family.
"From the beginning, I have said the signing of Neymar has been correct and his signing has caused despair and envy in some of our adversaries."
Rosell said he was resigning to spare the club's board of directors from "unfair attacks" that could "negatively affect their management or the image of the club".
He added: "It has been an honour to serve the Barcelonistas. It's been a privilege to be the president of FC Barcelona."
Rosell was named Barca president in the summer of 2010 after winning a landslide vote to succeed Joan Laporta, earning 61.34% of a record turn-out of 57,088 voters.
He had also been vice-president under Laporta before resigning in 2005.
Barcelona football club chief Sandro Rosell has resigned following a Spanish court's decision to look into last year's signing of Brazil star Neymar.