A California woman accused of trying to drown her newborn in a McDonald’s restroom avoided jail time last week after striking a plea deal with prosecutors and pleading no contest to felony child endangerment.

Sarah Jane Lockner, 27, received four years of supervised probation and was ordered to take parenting classes. SFGate reported, citing court documents. Lockner reportedly agreed to the plea deal in January. She was originally charged with attempted murder.

KEY WITNESS IN OAKLAND'S 'GHOST SHIP' FIRE TRIAL DIES BEFORE HE'S ABLE TO TESTIFY

Lockner was in the middle of a shift at a McDonald’s in Redwood City in the Bay Area in September 2017 when she was complaining of stomach pains, according to the San Mateo County District Attorney’s Office. When her fellow employees noticed she was trailing blood, Lockner told them she had a "heavy period."

A co-worker went to check on Lockner in the restroom and allegedly discovered Lockner with the newborn’s head face-down in a toilet bowl, according to prosecutors. Lockner reportedly told the co-worker not to call police, but the co-worker did anyway, according to the Mercury News of San Jose.

Responding officers found the baby not breathing and without a pulse, the newspaper reported. The baby was rushed to a hospital and survived. The child is reportedly staying with the father’s aunt.

CLICK HERE TO GET THE FOX NEWS APP

It wasn’t the first time this had happened to Lockner, according to prosecutors. She had given birth to another child in a restroom at home three years prior to the McDonald’s birth, prosecutors said. Lockner said both times that she didn’t know she was pregnant.