With Sanders threatening to upset Clinton in the first two nominating contests next month, the former secretary of state sought to stall his momentum, puncture his progressive credentials and raise questions about whether the self-declared socialist has the skills and experience to be president.
She used the final debate before voting starts in Iowa and New Hampshire to make a case to faithful supporters of Obama, who some Clinton allies worry might be shifting to Sanders. She'll need them to build a winning coalition capable of winning the Democratic nomination and mounting a successful race in the general election.
"I am going to defend President Obama for taking on Wall Street, taking on the finance industry and getting results," Clinton said.
Sanders, meanwhile, was far more comfortable in attacking Clinton than in his previous debate encounters, and the evening in Charleston, South Carolina, was notable more for personal clashes between the two of them rather than attacks on Republicans. He hit back at Clinton by insisting that Obama was his friend and took a swipe at Clinton over the lucrative months she spent on the speaking circuit after she left the State Department.
"I don't take money from big banks, I don't get personal speaking fees from Goldman Sachs," Sanders said.
Dynamics of the race
But, for all the passion and raised voices, it seemed unlikely that either Clinton or Sanders changed the dynamic of their race, which has them fighting tooth and nail in the first two states.
Recent polls in Iowa and New Hampshire also show Clinton in an increasingly precarious position. A Des Moines Register/Bloomberg Politics survey had Clinton up just two points in the Hawkeye State last week. A survey by Monmouth University in the Granite State last week had Sanders ahead by 14 points.
Clinton still holds a commanding lead over Sanders nationally. A new NBC/Wall Street Journal national poll on Sunday showed Clinton leading Sanders 59% to 34%, with the third candidate in the race, former Maryland Gov. Martin O'Malley, at 2%.
Clinton's strategy on Sunday involved clasping Obama as close as she could, ironically in a state where she clashed bitterly with the President during the 2008 campaign. Eight years later, African-American voters in the state could now provide a firewall against Sanders' rise.
She called the Affordable Care Act, "one of the greatest accomplishments of President Obama, of the Democratic Party, and of our country."
Fight over health care
And she warned that Sanders' plan for a Medicare-for-all universal health care unveiled hours before the debate, which would hike taxes on the middle class, would reopen a bitter debate with Republicans and could endanger Obamacare.
"To tear it up and start over again, pushing our country back into that kind of a contentious debate, I think is the wrong direction," she said.
Sanders was furious that after fighting for universal health care for decades, he was now being accused of sabotaging Obamacare.
"No one is tearing this up, we're going to go forward," said Sanders, complaining that 29 million Americans still lacked health care.
Clinton's decision to tie herself so closely to Obama could be a risky one if she wins the nomination and gets to take on the Republicans. While the President's approval ratings are very high among Democrats, a majority of Americans still disapprove of the job he is doing, so events in the economy and around the world could leave Clinton vulnerable by association with him.
Clinton sought to undermine Sanders in the opening moments of the debate by attacking him in one of the few areas where she can get to his left -- guns.
Divide on guns
She slammed her rival for voting "with the NRA, with the gun lobby numerous times," and reeled off a list of occasions when she said the Vermont senator sided with gun manufacturers and gun rights backers in Congress. She also said she was glad that he had "reversed his position on immunity," after Sanders backed away from a 2005 vote that gave gun manufacturers immunity from prosecution. He announced Saturday that he supports a proposed bill to amend that vote.
But Sanders hit back hard, arguing that he had a D-minus voting rating from the National Rifle Association and rejected her list of charges.
"I think that Secretary Clinton knows that what she says is very disingenuous," Sanders said.
The exchange was a powerful moment, unfolding on a debate stage just a block from the Charleston, South Carolina, church where a self-proclaimed white supremacist went on a shooting rampage last year that left nine African-Americans dead.
Sanders sought to catch Clinton off balance over the swift rise in his poll numbers over the last month, stirring fears among some Clinton supporters that history could be repeating itself, after her once "inevitable" 2008 Democratic primary campaign floundered when then-Sen. Obama won Iowa.
Sanders pointed out that when the campaign started, "she was 50 points ahead of me."
"Guess what: In Iowa, New Hampshire, the race is very very close," he said. "We are running ahead of Secretary Clinton in terms of taking on my good friend, Donald Trump."
Clinton hopes to use the debate to underscore her argument that she is the most electable Democrat, has the best experience required of a commander in chief and is more likely to beat a Republican in the general election.
The former secretary of state touted her connections to African-American voters, who are crucial in the Palmetto State primary and could form a firewall for her should she lose the first two contests in early February. When asked whether African-American lives are seen as "cheap," she responded, "Sadly, it's reality."
"It's been heartbreaking and increasingly outraging to see stories of young men like Walter Scott who have been killed by police officers," she said. "There needs to be a concerted effort to address the systemic racism in our criminal justice system."
A former North Charleston, South Carolina, police officer was charged in Scott's shooting death.
When the conversation turned to foreign policy in the second half of the debate, Clinton appeared more comfortable than Sanders, as would be expected for a former secretary of state.
She said she was "proud" of the nuclear agreement between Iran and world powers implemented this weekend. She said she paved the way for it by getting punishing international sanctions imposed on the Islamic republic when she served as secretary of state. But she warned it would be wrong to move too quickly toward rapprochement with Tehran.
"We have one good day over 36 years," Clinton said, after a week in which frenzied diplomacy resulted in the freeing of 10 U.S. Navy sailors captured by Iran's Revolutionary Guard Corps and a prisoner swap that saw four imprisoned Americans freed by Iran.
Clinton stressed that she had a three-point plan to crush ISIS in Syria and Iraq and to end the brutal civil war in Syria.
Seeking to hold his ground on foreign policy, Sanders, meanwhile, warned that it would be wrong to send more Americans into the "quagmire of Syria" and once again brought up the cautionary tale of the war in Iraq that Clinton, then a senator, voted to authorize in 2002. He said that another U.S. venture in the Middle East would be "an unmitigated disaster."
Clinton defended her signature first-term Obama administration policy of resetting relations with Russia. That effort later sputtered when Vladimir Putin returned to the presidency in 2012 and took a harsh turn against the United States.
She said with a smile that her relationship with Putin was "interesting" but was about respect. Clinton warned that Putin was "like many bullies" who would take anything he could get before someone stood up to him.
Once again, the debate was a frustrating experience for former Maryland Gov. Martin O 'Malley, who repeatedly complained that he was not getting equal time.
An hour before the debate started, Sanders unveiled his long-awaited new health plan -- a Medicare-for-all system that would be paid for by raising a series of taxes on the middle class. Clinton has previously questioned exactly how Sanders could make his plan add up. But Sanders aides argue that the tax increase people would face would be outweighed by the savings they would get under the system.
A Clinton victory in November would, of course, mark the return of Bill Clinton to the White House. As the debate wound down, Clinton was asked if she would take advice from her husband.
"It will start at the kitchen table," she said. "We will see where it goes from there."