A rowdy group of Bronx prosecutors took over the main evidence room in the NYPD ticket-fixing scandal — drinking and partying among the piles of tapes and files before a Yankee game, The Post has learned.

About 40 people, including prosecutors and their civilian guests, milled around room 617 during the boozy May 23 bash at the Bronx District Attorney’s Office, where, sources said, Internal Affairs probers keep the mountain of wiretaps and documents for DA Robert Johnson’s sweeping ticket-fixing case against 16 NYPD cops and five civilians.

“It could damage the whole ticket-fixing case,” a source who witnessed the revelry told The Post.

“If even one civilian got through the door, it’s a problem. Evidence must be safeguarded in a secure location.”

The door to room 617 is usually locked and bears a sign that reads: “No Unauthorized Entry.”

It’s unclear whether someone in IAB granted the city lawyers access or whether someone in the DA’s Office had the key.

During its ticket-fixing probe, IAB secretly recorded a staggering 139,000 phone calls and intercepted 311,000 text messages and e-mails. The judge in the case has said there are also an estimated 20,000 pages of grand-jury minutes and testimony.

“Evidence is everywhere in there, stacked in boxes, floor to ceiling,” one source said of room 617. “It’s the field office for Bronx IAB.”

“The reason this is a problem is that the room is supposed to be locked 24/7.”

“This will raise questions. This is no way to run an investigation. The Bronx DA will have to admit it happened . . . There were too many people, too many witnesses [not to].”

The Wednesday night party — a warm-up for that evening’s Bronx DA Night at Yankee Stadium — started at the Bronx’s DA’s sixth floor reception area, which had been set up as a bar, sources said.

But prosecutors, their girlfriends and other guests were soon milling in and out of room 617, a witness said.

“They were all right there, next to the evidence,” the witness said.

A spokesman for DA Johnson confirmed the pre-game festivities but insisted the party didn’t compromise evidence.

“Present and former staff members and their families gathered at the office prior to attending a Yankees game,” said DA spokesman Steve Reed.

“They conducted themselves maturely and did nothing to compromise the work of the office.”

One source scoffed at the notion that “families” were included in the boozy blowout and said there were no kids in sight.

“If your family includes a stable of hot women, then I guess you could call it a ‘family’ event,” the source said.

With the drinks free-flowing, several partygoers even bailed on the Yankee game.

“Most never made it to the game. It’s always that good of a party,” one source said.

It’s unclear whether IAB investigators or detectives and rank-and-file NYPD cops attended the festivities.

But one law-enforcement source heard cops discussing the party ahead of time.

“I heard people joking that this party was going on, and that we should go after them,” the source said.