One man was shot dead, and at least five others — including a cop — were injured as gunfire erupted during Monday’s pre-dawn festivities leading up to the West Indian Day Parade in Brooklyn, cops said.

During the fatal shooting, the NYPD detective was hurt when one of the bullets struck the rear window of his nearby unmarked tan Dodge Caravan mini-van and he was hit by flying glass, cops said. He was treated for cuts at a hospital and released.

The suspect, believed to be a 26-year-old man, squeezed off as many as 45 shots into a crowd during an argument and killed a 55-year-old man, cops said. It’s unclear if the victim was the intended target.

A 22-year-old man and 20-year-old woman were also struck by bullets but are in stable condition at Kings County Hospital.

The alleged shooter, who has 26 priors, was arrested after dropping the .45 semi-automatic gun, sources said.

NYPD Commissioner Bill Bratton, who later walked the parade route with Mayor de Blasio, called the parade a “well-structured event” and noted that thousands of cops were assigned to the area as well as to other city events Monday. He said helicopters had been brought in, too, to assist in crowd control and traffic.

De Blasio, who also was with his family, said, “There’s always a few individuals that get out of line. But the NYPD handles that very well.”

Other pre-parade shootings in the area included a 28-year-old woman who was shot in the buttocks at 226 Utica Ave. at 3:35 a.m. and a man, 22, shot in the foot on Sullivan Place an hour later, cops said.

No arrests have been made in any of those incidents.

Besides scantily clad dancers and throngs of rowdy revelers, the West Indian Day Parade, which spans a portion of Eastern Parkway, is notorious for such violent crime.

Last year, two people were fatally stabbed. And in 2012, two men, ages 26 and 27, died after being stabbed in the neck in separate incidents in areas just off the parade route.

The annual spate of parade violence is so bad that cops try to avoid working on the day at all costs, according to a law-enforcement source.

And the bloodshed “will only get worse under this administration,” the source said.

“They tell us zero enforcement on drugs and alcohol and that we’ll be waiting a long time for back-up if we need it,” the source said.