Residents heard cries from a public toilet block and notified police, according to the Beijing Times.
"Her head was upside down and her body was falling into the drain. We could only vaguely see her feet from the side," Qian Feng, the local police chief told the paper.
Qian said initially police decided to dismantle the toilet as the drain structure was unclear, but that would take too long.
"She just kept crying. I looked again, and thought we should try to pull her out even if the possibility might be slim."
In a police video taken during the rescue, Qian is seen kneeling by the toilet, reaching his right hand into the drain.
"There is a right-angled pipe inside the train, and the baby was almost trapped in the horizontal pipe," Qian told the Beijing Times.
After being pulled safely out of the pipe, residents helped police wrap the baby up before she was sent to a nearby hospital.
As of Monday night, she was in a stable condition, the newspaper said. It added that she had no apparent physical defects.
More abandoned babies
There are more than 100,000 abandoned children in China, Wang Zhenyao, co-founder of China's child welfare policy and a retired Ministry of Civil Affairs official told CNN in a 2014 interview
Most abandoned babies suffer from a range of disabilities and medical conditions, such as cerebral palsy, Down syndrome, congenital heart disease, club feet and cleft lip.
In May, police rescued a baby boy with a cleft lip who had been buried in the wilderness for 10 days in southern China's Guangxi province.
The Chinese government has opened dozens of baby hatches in the past five years in order to help parents safely give up their babies instead of abandoning them in the streets, or worse.
One baby hatch in eastern China's Shandong province reported last year that it had received 106 children with disabilities or medical conditions in the first 11 days it was open.
Another baby hatch in southern China's Guangdong province was temporarily shut down because it had been overwhelmed with abandoned infants two months after it first opened in January 2014.