A former New Jersey police officer will not be sent to prison despite fathering a child with a 15-year-old girl.

Rafael Martinez Jr. escaped a prison sentence on Friday after Judge Edward McBride accepted a negotiated plea deal that will see the former Camden County cop receive five-years-probation, according to NJ.com.

While giving birth last August at Cooper University Hospital in Camden, social workers interviewed the 15-year-old, who told them that Martinez was the father.

Camden County Police Detective Rafael Martinez Jr (pictured) pleaded to to endangering the welfare of a child on Friday after impregnating an underage girl

After confronting Martinez, 33, he admitted to impregnating the underage girl and signed the infant's birth certificate the night the child was born.

'They both admitted to the (social worker) that Martinez is the father of E.L.'s child and he signed the birth certificate confirming such,' the social worker said in a sworn police affidavit obtained by the Courier Post.

The infant's 15-year-old mother told officials that she and Martinez had sex at his Blackwood, New Jersey, home on several occasions between September 2016 and August 18, 2017.

Martinez's defense attorney, Dan Rybeck (pictured), said that the ex-law enforcement officer would like to be admitted to a weekly treatment program ran by the state

A DNA test later confirmed Matinez's paternity.

During his trial, however, Martinez maintained that he did not know the future mother of his child was underage.

In response, Deputy First Assistant Prosecutor Grace MacAulay said the excuse was not good enough.

'Saying the child told me she was 18, that is inexcusable and unacceptable for any person in our society, but especially for a law enforcement officer,' MacAulay said.

Martinez's defense attorney, Dan Rybeck, said that the ex-law enforcement officer would like to be admitted to the County Supplemental Labor Service Program on weekends.

In sentencing Martinez, McBride noted that 'his conduct is the result of circumstances that are unlikely to recur,' highlighting Martinez's previously unscathed record with the law.

In addition, Martinez pleaded to endangering the welfare of a child as part of the agreement with the court.

Martinez, whose father is also a Camden police officer, was suspended from the force without pay following his arrest on September 12.

His yearly salary with the police department had been $65,792 per year.

Martinez worked for New Jersey's Department of Corrections before becoming an officer in Camden in 2013.

He has received several honors for his police work, including a Meritorious Service award in July 2013 and Officer of the Week recognition

The suspension lasted until his case was adjudicated and was officially forced off of the department on Friday.