CHARLESTON, S.C. - Democratic presidential candidates Hillary Clinton and Bernie Sanders tangled repeatedly in Sunday night's presidential debate over who's tougher on gun control and Wall Street and how to steer the future of health care in America. It was the last Democratic matchup before primary voting begins next month and both sides were eager to rumble as polls showed the race tightening in the leadoff states of Iowa and New Hampshire.

Clinton rapped Sanders, the Vermont senator, for voting repeatedly with the powerful gun lobby, and then welcomed his weekend reversal of position to support legislation that would deny gun manufacturers legal immunity.

Sanders, in turn, said Clinton's assertion that he kowtowed to the gun lobby was "very disingenuous" and pointed to his lifetime rating of a D- from the National Rifle Association.

On health care, Sanders released his plan for a government-run single-payer plan just hours before the debate, and used his opening statement to call for health care "for every man, woman and child as a right."

Clinton, by contrast, urged less sweeping action to build on President Barack Obama's health care plan by reducing out-of-pocket costs and control spending on prescription drugs. She suggested Sanders' health care plan would impose a heavier tax burden on the middle class.

The two tangled over financial policy, too, with Sanders suggesting Clinton won't be tough enough on Wall Street given the big contributions and speaking fees she's accepted. Clinton, in turn, faulted Sanders' past votes to deregulate financial markets and ease up on federal oversight.

Clinton worked aggressively to associate herself with President Obama, claiming credit for her role in the run-up to the Iran nuclear deal as well as praising the health care law.

Turning to national security, both Sanders and Clinton voiced strong support for Obama's diplomatic overtures to Iran and opposition to sending U.S. ground troops into Syria. Clinton defended her outreach to Russia early in her term as secretary of state, but hesitated when asked to describe her relationship with Vladimir Putin, whose return to the Russian presidency heralded the worsening of U.S.-Russian relations.

"My relationship with him - it's interesting," Clinton said to laughs in the debate hall. "It's one, I think, of respect." But she added it was critical to constantly stand up to Putin, describing him as a bully who "will take as much as he possibly can."

Clinton also shed some light on what role her husband, former President Bill Clinton, would play in her administration. Kitchen table adviser, perhaps?

"It'll start at the kitchen table - we'll see where it goes from there," she said with a laugh.

Sanders was asked about his previous criticism of Bill Clinton's past sexual behaviour. He called the former president's behaviour "deplorable" but said he wants to focus on issues "not Bill Clinton's personal life." Clinton maintained a tight smile throughout that exchange, and nodded as Sanders said the focus should be on issues.

The debate over gun control - an ongoing area of conflict between Clinton and Sanders - took on special import given the setting: The debate took plan just blocks from the Emanuel African Methodist Episcopal Church where nine parishioners were killed during Bible study last summer. Gun control has emerged as a central theme in the race, with Clinton citing the issue as one of the major differences between the candidates.

The third participant in the debate, former Maryland Gov. Martin O'Malley, tried persistently to insert himself into the conversation. He focused on his record as Maryland's governor and accused both Clinton and Sanders of being inconsistent on gun control

Both Clinton and Sanders are competing for black voters in South Carolina, which hosts the fourth primary contest.

The debate was sponsored by NBC, YouTube and the Congressional Black Caucus Institute.