Backers of this weekend’s J’Ouvert festival in Brooklyn promised “the most extensive security ever,” after a stray bullet fired during a gang shootout at last year’s predawn street party killed an aide to the governor.

Violence has long marred the local celebration of J’Ouvert, a Caribbean tradition in its second decade in Crown Heights. Mayor Bill de Blasio said the NYPD and organizers are committed to making the festivities and the surrounding neighborhoods safe.

“A few bad apples over the years have caused trouble,” de Blasio said Wednesday at a Prospect Park news conference. “We are not gonna let a few bad apples destroy something that’s so important to hundreds of thousands of good New Yorkers.”

A bullet fired by a reputed gang member and meant for a rival in what investigators called a turf war, struck Carey Gabay in the head instead. Gabay, 43, a Harvard-educated lawyer, worked as first deputy general counsel at the Empire State Development, the state’s chief economic development agency.

The bullet hit Gabay about 3:40 a.m. on Sept. 7, 2015, as he walked at the festival, a precursor to the West Indian Day Parade.

Gabay died nearly 10 days later. The suspects in his killing are due back in court Sept. 7 — exactly one year after the shooting.

advertisement | advertise on newsday

Thousands of NYPD cops — double the number of last year’s force — are set to flood the neighborhoods along the party route. The overnight festival will be illuminated by 200 light towers. And the police have been visiting potential troublemakers like parolees to do spot checks and enforce open arrest warrants, according to Police Commissioner William Bratton.

For the first time, the event will receive an official city permit. It typically attracts about a quarter-million revelers.

Celebrants are expected to gather about 2 a.m. near Flatbush Avenue and Prospect Park, with a procession beginning at 4 a.m. It makes it way toward Empire Boulevard, Nostrand Avenue and Maple Avenue around 10 a.m.

“It’s a good six hours. We’ll have plenty of police officers,” said James O’Neill, the NYPD’s chief of department.

Gabay’s brother, Aaron McNaughton, who was with him at the shooting, said he hopes his brother’s story is a “deterrence to violence.”

“I’m hoping, with the new security measures, things are much better in place to prevent future Carey Gabays from happening,” he said after de Blasio’s news conference. “Whether you target a person or not, you can hit innocent people that have nothing to do with whatever quarrel you may have. It’s very unfortunate it had to be at the cost of my family.”

McNaughton said he won’t attend this year because the pain of his brother’s death is still too raw.