HOUSTON — There were brief calls for unity, and then a free-for-all. In a series of heated exchanges at a presidential debate here Thursday night, 10 Democratic contenders laid bare the party's deep divisions on major issues including health care, immigration and foreign policy during a debate that also featured personal swipes over honesty, mental acuity and the legacy of former president Barack Obama.

Former vice president Joe Biden began Thursday's presidential debate with an aggressive defense of his health-care proposal, attacking the more expensive and ambitious Medicare-for-all program backed by his top rivals in the Democratic race.

Biden, flanked by Sen. Elizabeth Warren of Massachusetts and Sen. Bernie Sanders of Vermont, went on offense early against the two liberal candidates, casting their universal health-care program as unworkable, too costly and a betrayal of Obama's signature legislative achievement.

"I know the senator says 'I'm for Bernie'," Biden said, turning toward Warren. "Well I'm for Barack."

Biden stressed that he wants to expand on the Affordable Care Act, commonly known as Obamacare, rather than replace it with Medicare-for-all, which is estimated to cost more than $30 trillion over 10 years.

Sanders and Warren largely joined forces to spar with Biden early in the debate, casting their plans as more properly suited to the major problems of the day.

In what served as a virtual battle over the soul of the Democratic Party, Thursday's debate highlighted key questions of whether the party should pursue policies of sweeping change or a more incremental return to normalcy in the wake of President Donald Trump.

Several candidates also tried to balance offering praise of Obama with giving themselves space to criticize Biden, who served as Obama's vice president for eight years.

The third Democratic debate came at an inflection point in the race, with a narrowing of the field that has started to clarify the campaign as it heads into the fall. The trio at the center of the stage — Biden, Sanders and Warren — have consistently held the top places in the polls, with the rest of the candidates trailing far behind and growing increasingly desperate.

But the lengthy discussion appeared to do little to change the overall contours of the Democratic primary, with few standout moments or major missteps during the course of the nearly three-hour event.

Warren, who has been ascendant in the polls in recent months, spent long stretches without speaking Thursday, and did not end up challenging Biden directly during her first face-to-face debate with the former vice president, who sits atop most polls.

Several other candidates were more than willing to take on their fellow Democratic contenders directly, despite beginning the debate saying they wanted to unify the country and highlight the party's broad unanimity on public policy.

"I don't think it's a bold idea, I think it's a bad idea," Sen. Amy Klobuchar of Minnesota said of Sanders' health-care bill.

"For a socialist, you've got a lot more confidence in corporate America than I have," Biden said to Sanders, scoffing at the idea that companies would pay workers more if they had fewer health-care costs.

Sanders later criticized Biden for voting for the Iraq War in 2002.

A sharp fault line quickly developed between Biden and former housing secretary Julián Castro, who took several opportunities to directly challenge the former vice president. Castro questioned Biden's memory and claimed that Biden was not adequately fulfilling Obama's legacy.

"Are you forgetting what you said two minutes ago?" Castro asked Biden, alluding to questions about the 76-year-old's age and mental acuity. In that exchange, however, Castro was misrepresenting what Biden had said two minutes earlier and Biden had not, in fact, forgotten.

When Biden was asked whether the Obama administration was too aggressive with its deportation policies, Biden responded, "The president did the best thing that he was able to do." After being pushed on whether he should have done more, Biden responded, "I'm the vice president of the United States."

Castro seized on the response, chiding Biden for boasting about the Obama administration successes but distancing himself from its problems.

"Every time something good about Barack Obama comes up he says, 'Oh I was there, I was there, I was there, that's me, too,' " Castro said. "And then every time somebody questions, or the administration that we were both part of, he says, 'Well, that was the president.' I mean he wants to take credit for Obama's work, but not have to answer any question."

"I stand with Barack Obama all eight years — good, bad and indifferent," Biden responded. "I did not say I did not stand with him."

For much of the debate, Democrats spent more time talking about the former president than the current one. Still, Trump loomed large on the debate stage as Democrats pilloried his policies and his behavior in office.

"Houston, we have a problem," Klobuchar said at the event's outset, invoking Trump. "We have a guy there who is literally running our country like a game show. He would rather lie than lead."

"And now, President Trump, you can go back to watching Fox News," Sen. Kamala Harris of California said at the end of her opening remarks, which she dedicated to attacking the president for "trying to sow hate and division."

"The most dangerous president in the history of this country," Sanders said of Trump.

Former congressman Beto O'Rourke called Trump a "white supremacist" and accused him of inspiring the gunman who traveled to El Paso, Texas, and killed 22 people last month. The White House has called such accusations disingenuous.

Trump campaign officials hosted an event for Hispanic voters in Houston and took out ads in the Houston Chronicle attacking Democrats on issues including taxes, energy and health care.

Speaking to reporters before the debate Thursday, Trump said he expected Biden, Warren or Sanders to win the Democratic nomination. He said he would not be watching the debate live, because it coincided with his visit to a House Republican retreat in Baltimore.

"I'm going to have to watch it as a rerun," he said.

Before the debate, a plane funded by the Trump campaign circled above Houston with a banner that read: "SOCIALISM WILL KILL HOUSTON'S ECONOMY! VOTE TRUMP 2020."

A Washington Post-ABC News poll released this week showed Trump trailing Biden, Warren, Sanders and Harris by significant margins in a general election. Trump has disputed the poll's accuracy.

The debate turned to guns, a topic that has ignited passion among Democrats. Biden, pressed on why he could be trusted to enact major new gun restrictions given his failure to do so as vice president after the 2012 massacre at an elementary school in Newtown, Connecticut, insisted that the political landscape has changed.

But there are limits to what a president can do, said Biden, who said that assault weapons can't be eliminated by executive authority, as Harris has proposed.

"I would say, Joe, instead of saying 'no we can't,' let's say 'yes we can,' " said Harris, a play on Obama's campaign slogan.

"Let's be constitutional," Biden said in response.

O'Rourke touted his plan for a mandatory government buyback of assault weapons. "Hell yes, we're going to take your AR-15 your AK-47," he said.

Andrew Yang, who had forecast that he would do something unique during the debate, said in his opening statement that he would expand a pilot program for his signature plan on universal basic income, which would give all Americans $1,000 per month. He said he would give away $120,000 to 10 families as part of the experiment.

While Yang spoke about artificial intelligence and the challenges it would cause in the coming decades, Biden at times sounded out of step with popular culture, imploring parents to make sure their children are stimulated by invoking technologies not in use by many Americans.

"Play the radio, make sure the TV, excuse me, make sure you have a record player on at night," Biden said. "Make sure that kids hear words, a kid coming from a very poor school or a very poor background here for a minute words were spoken by the time they get there."

Biden, cut off by the moderator, refused to stop speaking like he has in past debates: "I'm going to go on like the rest of them," he said.

It was a more aggressive stance compared with the previous two debates, when Biden found himself repeatedly on the defensive.

Biden and his allies have been attempting to cast his record as one that liberals in the party should be proud of and one that is more realistic than the more far-reaching promises offered by Sanders and Warren. They have also attempted to portray Warren as hypocritical for raising money from big donors up until this year during her presidential campaign.

On Thursday, the vice president began the debates with direct challenges to his top rivals on one of the most divisive issues in the Democratic primary: health care.

"How are we going to pay for it?" Biden asked of the Medicare-for-all plan backed by Sanders. "This is about candor. Honesty. Big ideas."

Several candidates tried to balance offering praise of Obama with giving themselves space to criticize Biden, who served as Obama's vice president for eight years. Warren said that "we all owe a huge debt to President Obama" and tried to frame Medicare-for-all as an improvement on Obamacare.

Pressed on whether middle-class families would see a tax hike to fund the program, Warren dodged the question. "Middle-class families are going to pay less," she said, focusing on overall costs.

Sanders, whose voice was hoarse, also said that families are looking for "effective" health care.

In the early portions of the debate, multiple candidates spoke highly of Obama and his role in shepherding through an expansive health-care plan. Obama has opted not to endorse any candidate in the primary.

Before the debate Thursday morning, Biden released a video touting working with Obama in the White House.

"Barack Obama was a great president," Biden wrote on Twitter. "We don't say that enough."

O'Rourke was in his home state, the place where he narrowly lost to Sen. Ted Cruz, R-Texas, last November. He has tried to refocus his campaign by orienting it more toward running against Trump. In the wake of a mass shooting in his hometown of El Paso, he has also proposed more aggressive gun-control measures and, in channeling some of the moral outrage, has gone back to using expletives on the campaign trail. Candidates were warned ahead of the debate to avoid "foul language."

The debate only briefly touched on foreign policy, with candidates largely united in criticizing Trump's approach to China, the Middle East and elsewhere.

Warren said she would begin withdrawing troops from Afghanistan immediately if elected, with or without a deal with the Taliban.

Buttigieg, a veteran who served in Afghanistan, said he would require Congress to reauthorize any war at least once every three years, to combat the problem of "endless wars."

Biden said he was "opposed to the surge" of troops in Afghanistan that took place under Obama, and that he would call troops home as well. He also said "I should've never voted" for the Iraq War.

Thursday's debate marked the third round of 12 scheduled Democratic debates, and the first in which a large portion of the declared candidates did not qualify. Several candidates who failed to meet minimum polling and donor targets set by the Democratic National Committee were kept off the stage.

Some of those candidates, including self-help author Marianne Williamson and Rep. Tulsi Gabbard of Hawaii, are within striking distance of qualifying for the next round of debates next month.