A state lawmaker lashed into the city yesterday for protecting the jobs of incompetent and sometimes dangerous teachers by sentencing them to do-nothing jobs in Department of Education “rubber rooms.”

“New York City must no longer permit a gift of several million dollars for incompetent former teachers who sit in the infamous ‘rubber rooms,’ drawing full salary while the Department of Education drags its feet and refuses to promptly address allegations of teacher misconduct and incompetence,” state Sen. Ruben Diaz (D-Bronx) fumed.

“What uniform service gets the benefit of ‘suspended with pay’ without any work responsibilities?”

Diaz trashed the DOE after The Post exposed two cases in as many weeks of male teachers accused of sexual misconduct receiving taxpayer-funded salaries.

The city welcomed Diaz’s angry response.

“The silver lining here is that Albany leaders are finally getting fed up with the rotten options that state law and labor rules give us for cases like this, and are starting to talk about the kind of changes we’ve long been pushing for,” DOE spokesman David Cantor said.

Diaz was outraged over the free-ride status of math teacher Francisco Olivares, who has been drawing a city paycheck even though he hasn’t set foot in a classroom for seven years.

Olivares, 60, is collecting $94,154 annually despite being exiled over criminal allegations that he sexually molested two 12-year-old students a decade after allegedly impregnating a 16-year-old girl he met when she was his 13-year-old student at a Corona junior high school.

Olivares is one of 660 rubber-room teachers on the city payroll who are awaiting disciplinary proceedings.

Joining Olivares on the sidelines is typing teacher Alan Rosenfeld, 64, who was banned from the classroom in 2001 for allegedly making lewd comments and leering at girls at IS 347 in Queens.

Rosenfeld, a lawyer, makes more than $100,000 a year as an exiled teacher, and has used his time in a Brooklyn rubber room working on his law practice and overseeing more than $7 million in real-estate investments.

A jury found Olivares guilty of snapping pictures of a girl with her pants down, and rubbing up against another girl from behind, but his conviction was reversed on appeal because of techicalities.