A tenant heard the baby's cries and notified authorities, according to the state-run news site Zhejiang News. The incident happened in Zhejiang province in eastern China on Saturday.
Firefighters narrowed the baby's location to an L-shaped section coming from a public restroom toilet. They cut out the section and carefully dismantled it, freeing the baby boy, who greeted the rescuers with cries.
Despite what he's been through, the baby is safe at the hospital. The boy is being called Baby No. 59 from the number of his hospital incubator.
Police are treating the incident as an attempted homicide and are looking for his mother.
The baby's rescue has prompted an outpouring of support from complete strangers, who are bringing diapers and other supplies to the hospital.
The Associated Press contributed to this report.