The opposition began campaigning for Slipper's removal after offensive text messages he sent to a former male staffer became public, the Australian Broadcasting Corp. reported.
The opposition's motion was voted down, 70 to 69.
"The interests of the Parliament are seriously more important than the interests of any of us, and I respect this Parliament too much to not put aside my personal interests," Slipper said in announcing his resignation.
Anna Burke, a a member of the Labor party who had been acting in Slipper's role, was elected the new speaker.
Former staff member James Ashby has filed sexual harassment charges against Slipper.
Text messages between Slipper and Ashby in which Slipper described female genitalia in offensive terms were revealed in court documents Monday.
Slipper apologized for the messages Tuesday. While they were meant to be private, he said their content could not be excused.
Many were sent before he became speaker, Slipper said.
Slipper will continue to hold his seat in Parliament.
Police: Sword-wielding man demanded free tacos
Wisconsin business offering 'therapeutic cuddling' forced to close