Sen. Bernie Sanders and Hillary Clinton attacked each other in Sunday night’s Democratic debate with a ferocity neither has displayed in previous encounters as polls showed the race narrowing.

Clinton and Sanders clashed over health care and gun control and Wall Street’s power. The debate was the last before the Iowa caucuses on Feb. 1 and the New Hampshire primary, set for Feb. 9.

Former Maryland Gov. Martin O’Malley struggled to insert himself into the debate, and criticized Sanders and Clinton for inconsistent stands on issues.

See alsoBush, other GOPers' tweets PhotosCheat sheet: Fast facts on Democratic presidential contendersPhotos41 funny, revealing quotes from the Democratic debate

Clinton, a former secretary of state and former U.S. senator from New York, said Sanders’ single-payer health care plan, unveiled hours before the debate, would represent a retreat from Obamacare, and that he had flip-flopped on gun control.

Clinton vigorously defended President Barack Obama’s Affordable Care Act. “We finally have a path to universal health care,” Clinton said. “And I don’t want us to start over with a contentious debate.” She criticized Sanders’ plan as too expensive.

“That is nonsense,” said Sanders, who represents Vermont. “What a Medicare for all program does is finally provide health care for every man, woman and child as a right.”

advertisement | advertise on newsday

Sanders said his plan would be funded by premiums paid by individuals and families, a 6.2 percent payroll tax, and an increased tax on families making more than $250,000 a year.

Clinton and Sanders also tangled over gun control, a top Democratic issue.

Sanders over the weekend said he would support changes to a 2005 law he voted for that protects gun manufacturers from liability in shooting massacres.

@Newsday

“He has voted with the NRA, the gun lobby, numerous times,” Clinton said as Sanders smiled and shook his head. “I am pleased Sen. Sanders has reversed himself on immunity.”

“I think Secretary Clinton knows that what she says is very disingenuous,” Sanders replied as Clinton glared directly at him. He noted his D-minus grade from the National Rifle Association despite representing a state with a strong hunting rights tradition. He said his mixed record reflects listening to all sides.

“I support what President Obama is doing,” Sanders said. “This should not be a political issue. What we should be doing is working together.”

Sanders tried to put Clinton on the defensive, saying the nation’s biggest problem is that the economy is “rigged” by Wall Street interests that contribute millions of dollars to candidates, including Clinton, in a “corrupt” campaign finance system. He accused Clinton of accepting $600,000 in one year for speeches to Goldman Sachs on Wall Street.

“I don’t take money from big banks and I don’t get personal speaking fees from Goldman Sachs,” Sanders said. “If Teddy Roosevelt was alive today, the old Republican trustbuster, he’d say these guys are too powerful. Break them up.”

advertisement | advertise on newsday

Clinton said “there is no daylight” between her and Sanders on the need to keep Wall Street in check, to avoid another recession triggered by wrongdoing by big banks. She told Sanders she doesn’t mind the criticism — “I can take that” — but expressed anger over what she called Sanders’ unfair criticism of Obama.

“I’m the one they don’t want to be up against,” she said.

“It’s just not true,” O’Malley said. He blamed the Obama administration and Clinton for failing to adequately protect the economy from Wall Street abuses in the future. He said he would put more enforcers on Wall Street.

“If a bank robber robs a bank and you just slap their wrists, he’s going to rob banks again,” O’Malley said.

Clinton called for strong military action against the Islamic State terrorist group. But when asked whether she could foresee deploying significant numbers of American forces, she replied: “Absolutely not.”

advertisement | advertise on newsday

Sanders said the U.S. should “train and provide support for Muslim countries that are prepared to take on ISIS.” But he said Qatar, Saudi Arabia and other nations in the region had to “put some skin in the game” in the fight against Islamic terrorists.

O’Malley expressed concern about the lack of intelligence on the ground in the region.