A 6-year-old girl was being tucked into bed one night last March when she told her mother she had a secret, prosecutors said.

The girl, who was recovering from a brain tumor, said she had touched her father’s genitalia and made her mother promise not to tell, according to court documents.

“If you tell everybody in the whole wide world, he’ll go to jail ’cause it’s a secret,” she said, according to a probable cause affidavit filed in court in Marion County, Ind.

But the girl’s father, 41-year-old Jeremy Schwer, won’t be going to jail.

Instead, he has been sentenced to 12 years probation for felony child molestation after his now-estranged wife wrote a letter to a judge, urging him not to put Schwer behind bars, according to the Indianapolis Star.

The mother, who has filed for divorce, told the judge she needed Schwer to work to provide financial support her and their two children.

“He’s not a bad man; he made a mistake,” Schwer’s attorney, John Campbell, told The Washington Post.

Campbell said the judge’s intention was for Schwer “to keep his job and help his wife and two little children with health insurance and expenses.” But the negative media attention, he said, has made his client unemployable in Indianapolis — “a town where where everybody knows everybody else’s business.”

Indeed, it’s not Schwer’s conviction — but rather his sentence — that has presented questions about how and why a child molester avoided prison.

The girl, now 7, was diagnosed with a brain tumor in August 2013 — a moment that led the child and her family through an intense period, according to court documents.

That fall, the girl had surgery to remove the tumor. She was sent for follow-up treatment at St. Jude Children’s Research Hospital in Memphis, where she lived for four months. Over the next year, she fought through chemotherapy.

Throughout that time, according to the court documents, Schwer stayed by her side.

“Jeremy would stay in her bed until she fell asleep and he would sometimes fall asleep in the bed with her,” according to the probable cause affidavit. “He would also occasionally sleep on a mattress on her floor and he would sometimes come into the bedroom and sleep on the bed” with her.

“He would also sleep on the couch or on a mattress in the living room, sometimes.”

Schwer was described as a “perfect daddy figure,” according to the documents.

But that night in March 2015, in the family’s Indianapolis home — where there was a princess castle from the Make-A-Wish Foundation — the girl opened up to her mother.

“Mommy, I touch my daddy’s peepeeluca,” she said, referencing her father’s genitalia, according to the probable cause affidavit.

Authorities said the girl later told child protection services that she would sit on her father’s “cat tail.”

“Promise you won’t tell,” she told authorities, according to the court documents.

When the child’s mother confronted Schwer, he said, “No, no, no, I was asleep and she touched it one time in my sleep,” according to the court documents.

“I didn’t hurt her,” he insisted.

“I didn’t hurt her.”

Under Indiana law, it is considered child molestation when someone “knowingly or intentionally performs or submits to sexual intercourse or other sexual conduct” with a child under the age of 14.

Schwer was charged with “foundling or touching” his daughter between July 10, 2014, and March 6, 2015, according to court records.

Marion County Deputy Prosecutor Courtney Curtis fought for a nine-year prison sentence.

But after Schwer entered a guilty plea Tuesday, Marion Superior Court Magistrate Steven Rubick instead sentenced him to 12 years probation, the Indianapolis Star reported, citing court records. For the first six years, he will be on GPS monitoring, according to NBC Chicago.

Schwer was ordered to register as a sex offender and vacate the family home, according to reports.

Chris Newlin, executive director for the National Children’s Advocacy Center, said families in sexual-abuse situations are sometimes financially vulnerable — particularly when the abuser is the primary provider.

In those cases, Newlin said, it’s not a question of wanting an abuser to be free to abuse again. “It’s an issue of wanting to be able to survive,” he said.

Society may see prison time as the appropriate punishment in child abuse cases, Newlin said; but that same society is responsible for helping to support a child when his or her parent is behind bars.

That’s one reason, he said, judges are beginning to “look with some latitude” at some cases, taking all factors into consideration when deciding punishment.

For instance, he said, a father who abuses his child and then takes responsibility is very different from a father who abuses his child and then denies it.

Campbell, Schwer’s attorney, said his client did accept responsibly for his actions, pleading guilty to charges of felony child molestation.

But Campbell said Schwer, who works in information technology, was fired from his job due to media coverage of the case, making it impossible for him to do the very thing the judge intended for him to do — provide for his family.

Campbell blames the prosecutor in the case.

“I think what the prosecutor has done is harm the little girl far more than her father ever did,” he said, referring to “emotional turmoil and financial hardship.”

The prosecutor’s office declined comment.

But according to the Indianapolis Star, Curtis, the deputy prosecutor, said the sentence was unfortunate.

“This is the most horrific circumstance of a child molest case that I’ve ever seen,” she said.