The number of city students busted for sex crimes has increased each of the past three years — with rape arrests tripling over that span, according to new NYPD records.

During the 2016-2017 academic year — when the department began compiling quarterly school crime data — five city students were arrested for rape.

That number shot up to 12 for the 2017-2018 school year and hit a three-year high of 15 this past school year, according to a Post analysis of NYPD numbers.

While those crimes involved students, they did not necessarily take place on school grounds, the Department of Education noted.

The rise in sex crimes mirrors an annual increase in felony student arrests over the past three years.

There were 34 felony sex crime busts during the last academic year — up 161% from two years ago when there were only 13.

The 2017-2018 school year saw a total of 31 felony sex crime collars in city schools, the figures show.

That offense category includes rape, promotion of sex by a child, and aggravated sexual abuse.

Overall, there were a total of 72 student sex crime busts involving the NYPD this past school year — up 76% from two years ago when there were 42.

There were 68 instances last year.

Those figures include misdemeanor sex-related incidents including forcible touching.

The DOE asserted Tuesday that while the number of students busted for sex-related crimes rose last year, the number of overall incidents dropped. A single case, they said, could involve multiple kids. They were unable to specify or document that claim.

Of the 32 city students arrested for rape over the past three years, 18 were in high school at the time, according to the NYPD.

A total of 14 of students busted for the crime were collared in middle and junior high school — and two arrests occurred in elementary schools, the reports show.

The NYPD’s school crime reports only document NYPD-enforcement incidents at city schools.

The state compiles separate school crime figures that originate with teacher incident reports. During the 2017-2018 school year, the state counted 447 “forcible touching” incidents in city schools — a figure the DOE attributed to stricter reporting guidelines that now include less severe cases.

While the Department of Education continues to grapple with sex crime, most other offense categories — including assault — dropped sharply last year, according to the NYPD.

Assault cases plummeted to 303 during the 2018-2019 school year from 500 in 2016-2017 — a 39% plunge, according to the statistics.

Critics argue that the DOE has been applying pressure to school administrators to suppress school crime incidents.

Principals, they contend, are reluctant to report misconduct in order to protect their school’s reputation.

The DOE has staunchly denied that claim and has credited improved enforcement procedures and school climate for drops in major crime categories.

Drops in school misconduct, Mayor Bill de Blasio has argued, expectedly mirrors the city’s overall crime drop during his time in office.

“While overall crime and sex crime in schools continue to decrease, there’s no tolerance for sexual misconduct, and we work hard to make our schools safe and inclusive places where students feel empowered to speak up if anything inappropriate happens,” said DOE spokeswoman Miranda Barbot.

The NYPD also weighed in.

“The vast majority of these incidents were offsite and the NYPD worked with the DOE to address appropriately,” said NYPD School Safety Assistant Chief Ruben Beltran. “Overall crime continues to go down in schools to record lows, and we will continue to ensure safe school communities.”