The decision is a blow to Prime Minister Pedro Sánchez, who defended García Ortiz during the months-long investigation and trial.
Spain's Supreme Court found the country's Attorney General Álvaro García Ortiz guilty on Thursday of leaking confidential information about the boyfriend of a leading conservative politician and government rival.
The court banned García Ortiz from his post for two years in a 5-2 split.
The decision was released by the court in a short statement and the complete verdict has not been made available.
The government said that it would start the process to nominate a new attorney general in the coming days.
The decision is a blow to Spain's Prime Minister Pedro Sánchez, who defended García Ortiz during the months-long investigation and trial.
The Spanish government said that it "respected the decision but does not share it."
García Ortiz was accused of leaking an email to journalists and of writing a press release containing personal information about Alberto González Amador, when the businessman was under investigation for alleged tax fraud.
That tax inquiry remains open.
González Amador is the partner of Madrid's influential regional leader Isabel Díaz Ayuso, one of Spain's foremost opposition leaders.
García Ortiz denied any wrongdoing and can appeal to the Constitutional Court.
In addition to being removed from his post, the court ordered that he pay €7,200 in fines, €10,000 in damages to González Amador and the court fees.
The trial earlier this month gripped Spanish media. This was the first time in Spain’s modern history that a top prosecutor faced a criminal trial.