He has no shame.

A married Queens teacher and dad who repeatedly had sex with a 13-year-old girl in his family’s home openly made out with his lawyer wife in court yesterday — minutes before landing a sweetheart jail deal for his rape charge.

As a Queens judge dispensed criminal cases feet away, Daniel Reilly, 36, shared long, passionate kisses with wife Annemarie, 28, who rubbed his knee and held his hand as they sat in the courtroom’s fourth row.

Reilly — who has a 1-year-old daughter with his wife — had sex with his sixth-grade student in his and his wife’s bed at their Forest Hills home at least a dozen times while his family was out, authorities have said.

The teacher had pursued the child until she finally agreed to the sick affair, and he used code names to hide their trysts for at least seven months beginning in August, officials said.

The IS 237 English teacher, who resigned last week, pleaded guilty yesterday to felony second-degree rape for the affair, a crime that can carry a sentence of up to seven years behind bars.

But under a deal designed at least partly to spare his young victim a trial, Reilly received just four months’ prison, plus 10 years’ probation.

He also must attend 104 sex-offender classes, and his teacher’s license was revoked.

“Like other politicians and public figures, he strayed and only thought with the lower half of his body. It was a mistake,” one of the ex-Marine’s two lawyers, Eric Franz, said afterward.

Annemarie Reilly, wearing a black-and-white tweed jacket, white top and black pants, refused to comment after court.

She had posted $30,000 bail for her cheating hubby when he was first busted in April — on the day he supposedly last hooked up with his teenage student.

Annemarie also was at his side for a previous court hearing.

Reilly, dressed down in gray sweat pants and a black warm-up jacket, was to start serving his term at Rikers immediately. The move is in advance of his formal sentencing in July.

The judge agreed to his lawyers’ request that he be put in protective custody at Rikers. And Reilly was allowed to take along two big bottles of an unknown prescription medication.

As he was taken from the courtroom, Reilly glanced back at his wife. Her eyes met his, but the pair said nothing.

The couple is moving to Nassau County to start a new life once Reilly is freed.

Reilly joined the city Department of Education in 2007. He earned $61,000 a year. He was taken out of the classroom after the charges surfaced.

Additional reporting by Kate Sheehy and Yoav Gonen