NEW YORK — Democratic New York City Mayor Bill de Blasio fended off barbs on Tuesday from Republican Assemblywoman Nicole Malliotakis and independent Bo Dietl in a raucous first mayoral debate of the general election.

The slugfest at Symphony Space on the Upper West Side of Manhattan was often interrupted by booing at the mayor and counter chants of “four more years.” Half of the event featured questions submitted by the public.

Dietl, a businessman and former police detective who said he would get things done as mayor, started the debate with a “Go Yankees!” and a zinger at the mayor for being a Boston Red Sox fan.

The hour and a half debate soon turned serious as both Malliotakis and Dietl double-teamed the mayor throughout the night.

“I was mugged 400 times. I was stabbed. I was shot at. I was hospitalized 30 times. I helped the people of New York City,” Dietl said.

The Staten Island assemblywoman said the city was mismanaged and broken, and that she was ready to clean up de Blasio’s mess.

“Bill de Blasio has abused the working class, spending more of our money and getting no results,” said Malliotakis, who noted that her parents were immigrants from Greece and Cuba and that she was the first in her family to attend college and get an MBA.

De Blasio, who is seeking a second term in the Nov. 7 election, countered by calling his two opponents “right wing Republicans who voted for Donald Trump.” He also noted his achievements, including universal prekindergarten and lowering the crime rate.

“We have a city that is now the safest big city in America. We have more jobs than ever before. Our graduation rate is up. Our test scores are up. We’re making progress in the city,” de Blasio said. “I need your help to continue the progress.”

Dietl tried to bring some levity back when he offered the mayor a backhanded compliment by praising “that pre-K stuff.”

“Maybe I’ll put you in charge of that,” Dietl quipped.

The tension returned as Malliotakis went after the mayor by citing a 25 percent increase in felony sex crimes.

“The mayor likes to say that New York City is the safest big city in America. That is not true if you are a woman in New York City,” said Malliotakis.

Both challengers also bashed the mayor on his handling of the homeless and wasteful spending, but the six-foot-five-inch de Blasio kept his cool as he stood above the fray.

“What you have heard is classic right wing scare tactics,” the mayor responded.

A second debate is scheduled for Nov. 1