One out of every four New York City government workers pulled in pay of more than $100,000 last year — thanks largely to overtime, according to a new study.

“New York City can be a hub of opportunity, and not just for aspiring Broadway stars. All sorts of city workers earn big bucks,” said Adam Andrzejewski, CEO of the government watchdog OpenTheBooks.com, which conducted the study.

About 37,000 of 295,455 full-time city workers receive a salary that tops $100,000.

But the number jumps to 76,166 when factoring in overtime and other extra pay, the group said.

The supplemental pay accounts for 12 percent of the workers’ total compensation, or more than three times the 3.5 percent rate in the private sector, according to the study.

Some career choices proved particularly lucrative.

Of the 775 school custodians, 694 cleared $100,000 or more.

And of those 694, 398 exceeded $150,000.

As a result, many custodians made more than principals — who earn between $135,000 and $163,000.

Andrzejewski said New York City is an outlier when it comes to custodians.

“At OpenTheBooks.com, we post 15 million public-employee salaries across America. Only in New York City do the janitors out-earn the principals,” he said.

Some teachers and school administrators were members of the same $100K-plus club.

Of the 106,263 educators working in the school system, 15,821 made the cut.

Tradespeople emerged as big winners at the NYPD, where 39 employees — including stationary engineers, oilers, thermostat repairers and plumbers — made more than the $217,442 paid to the police commissioner in 2016.

Overtime was the biggest driver.

There were 30,942 employees who received between $20,000 and $49,999 in OT, 3,307 who made between $50,000 and $99,000 and 160 who hit the jackpot with $100,000 or more.

Mayor de Blasio’s office defended the higher compensation.

“New York City’s dedicated public servants, including our police officers, teachers and firefighters, are the hardest-working in the world, and New Yorkers see the results of that hard work every day,” said mayoral spokeswoman Freddi Goldstein.

“Occasionally, overtime is necessary to face unplanned events or meet critical operational need. But we take our fiscal responsibility seriously and are constantly monitoring use citywide to determine if there are areas where we can do even better.”