The Democratic candidates running in this year's presidential election agreed Sunday that the implementation of the nuclear deal with Iran and release of U.S. citizens represent a positive step in relations, while also calling on countries in the Middle East to do increase their role in the fight against Islamic State.
Former Secretary of State Hillary Clinton said more needs to happen before moving rapidly toward normalizing relations with Iran, and the U.S. needs to pressure Iran further on "bad behavior" in the region such as its actions in Syria.
Vermont Senator Bernie Sanders, who has been gaining on Clinton in polls in the past month, said the existence of a nuclear deal without war and the thaw in the relationship between the U.S. and Iran are "very positive."
But he said he would not immediately open an embassy in Tehran, instead pointing to the U.S. and Cuba as an example of moving toward warmer relations with an important country.
Foreign policy positive
John Hudak, a senior fellow in government studies at the Brookings Institution, said that any time foreign policy comes up in the campaign it is good for Clinton.
WATCH: Where the candidates stand on Iran
"She obviously has the most experience on the issues, she's obviously the most comfortable talking about the complexity of these issues and the consequences of them," Hudak said.
"Bernie Sanders likes to talk a lot about his vote on the Iraq war, but I think for the most part America has moved past Clinton's decision on that and accepted her apology on that. At the end of the day, she looked ready to lead as commander in chief, Sanders did not look as prepared and (former Maryland Governor) Martin O'Malley looked completely over his head," he added.
The debate in South Carolina was the fourth for the Democrats and their last chance to discuss important issues in the same room before the first voters get to have their say at caucuses in Iowa on February 1.
In the Middle East, Clinton, Sanders and O'Malley all agreed the United States should not be solely responsible for acting against the Islamic State group.
Sanders said it is time for wealthy countries in the region such as Saudi Arabia and Qatar to get involved, and advocated work on a political solution in Syria that includes Russia, Iran and Muslim allies.
Clinton said there are a lot of forces at work in the region that the United States cannot influence, and praised President Barack Obama's strategy of backing local fighters, leading coalition airstrikes and working toward a diplomatic solution.
From left, Democratic U.S. presidential candidates former Maryland Gov. Martin O'Malley, former Secretary of State Hillary Clinton and Senator Bernie Sanders of Vermont participate in a debate in Charleston, S.C., Jan. 17, 2016.
O'Malley called attention to what he said is a shortage in intelligence gathering and assets in the Middle East, and called for a more "proactive" national security strategy.
While the candidates agreed on a lot in the realm of foreign policy, they sparred more on domestic issues including gun control, healthcare and campaign finance.
Ahead of the debate, Sanders introduced a new plan that he says would ensure health care is a right for every American.
Clinton criticized Sanders, accusing him of wanting to tear up Obama's landmark health care program and start over. She instead advocated building on the Affordable Care Act and improving it.
Sanders blamed the health insurance and pharmaceutical lobbies for keeping the cost of health care in the United States high.
He also called for more regulation of the banking industry, saying financial institutions have too much power over the economy.
Wall Street reform
Clinton said she has a plan to take regulations further, but Sanders said he has doubts about whether Wall Street reform is really possible when politicians receive huge amounts of money from the financial industry.
WATCH: Where the candidates stand on gun control
The three candidates paid tribute to civil rights leader Martin Luther King Jr., who is honored with a national holiday Monday, and said they want to raise the country's minimum wage, create jobs and make sure everyone gets equal pay for equal work.
But Clinton reiterated her critique of Sanders' policy on gun control, accusing him of doing a "flip-flop" on the question of whether gun manufacturers can be sued and voting on the side of the National Rifle Association numerous times.
Sanders called her criticism "disingenuous" and said he has always stood up to gun lobbyists. The senator said gun control should not be a political issue, and that a small gun store should not be sued for a legal gun sale if that weapon is later used in a crime.
Struggled for speaking time
O'Malley, who trails far behind in polls and has struggled to get speaking time in debates, said he has been hearing a lot of inconsistency on gun control from both Clinton and Sanders and that he is the only one of the three who has not changed his gun policies.
The Democratic presidential candidatesparticipated in the NBC, YouTube Democratic presidential debate at the Gaillard Center, in Charleston, S.C., Jan. 17, 2016.
The latest polls have Clinton and Sanders nearly tied in Iowa and give Sanders a 14 percent lead over Clinton in New Hampshire, where the first in the nation primary will be held early next month.
A new NBC News/Wall Street Journal poll issued before the debate puts Clinton ahead of Sanders by 25 points nationally.
But Sanders pointed out that Clinton at one time had a 50-point lead.
O'Malley has been polling about 2 percent and Sunday's debate could be his last chance to convince voters that he should be the Democratic nominee.
For the Republicans, the same poll puts Donald Trump on top with 33 percent, followed by followed by Texas Senator Ted Cruz at 20 percent support, Florida Senator Marco Rubio at 13 percent and retired surgeon Ben Carson at 12 percent.
Katherine Gypson contributed to this report.