Manuel Moix, who was in post for just four months, has denied any wrongdoing.
He confirmed he has a stake in a company in Panama, inherited from his father by him and his siblings.
The opposition Socialist Party argued this made him unfit to investigate prosecution.
Public Prosecutor Jose Manuel Maza defended Mr Moix's record, telling a news conference he was "satisfied there is absolutely nothing in the way he behaved that has been irregular or illegal".
Spain has been gripped for years by a long-running corruption scandal involving the ruling centre-right party, the Partido Popular (PP). The party lost its absolute majority in parliament after allegations about a cash-for-public-contracts scheme.
Prime Minister Mariano Rajoy is not accused of wrongdoing but will testify in court next month as part of the investigation.
Mr Moix was an unpopular choice for the anti-corruption role among opposition parties, who accused him of trying to shut down investigations into the Madrid branch of the PP.
Some have publicly welcomed his resignation, including the secretary general of another party, Podemos, who tweeted (in Spanish) about the need to get rid of "offshore ministers who degrade democracy".
The anti-corruption prosecutor in charge of investigating members of Spain's ruling party has resigned after it emerged he holds a 25% stake in an offshore company.