"I have decided not only to leave the justice ministry but also to give up politics," he told a news conference, hours after Prime Minister Mariano Rajoy said the government had abandoned the reform.
Ruiz-Gallardon, 55, was the first of the current government's ministers to be forced to quit since the conservative Popular Party took power in 2011.
Rajoy's government has survived protests over corruption scandals, economic cutbacks and labour reforms, but the abortion reform proved too divisive.
As well as street demonstrations by both opponents and supporters of abortion reform, it sparked dissent within the ruling party itself.
After nearly three years of delays, Rajoy said on Tuesday he was dropping the most contentious parts of the proposed reform, which would have ended women's right to freely opt for abortion up to 14 weeks into a pregnancy.
"We will continue studying ways to obtain greater acceptance of the reform, but I think I have taken the most sensible decision at this time," Rajoy told reporters.
Ruiz-Gallardon left his post as mayor of Madrid to join Rajoy's government in December 2011.
"I will not take up any more political posts," he said on Tuesday, announcing the end to his 30-year career.
Gallardón had already announced he felt discredited by allegations in the Spanish press last week that Prime Minister Mariano Rajoy had changed his mind over the controversial draft bill.
The draft reform, approved in January, would have allowed abortions only in cases of rape which had been reported to the police or when there was a medically-certified threat to the mother's physical or psychological health.