The candidates for the Democratic presidential nomination clashed for just under three hours Thursday night, a gathering that laid bare the generational and ideological splits facing the party that have formed the undercurrent of months of campaigning.

On issues from health care and race to guns and immigration, the candidates demonstrated how the party has lurched to the left, and how some continue to resist that pull. Former vice president Joe Biden came in for criticism of Obama administration policies, including its foreign policy and deportation moves — although the candidates were careful to reverse their strategies from the July debate and praise Obama himself.

The candidates facing off were Biden; Sens. Elizabeth Warren (D-Mass.), Bernie Sanders (I-Vt.), Kamala D. Harris (D-Calif.), Cory Booker (D-N.J.) and Amy Klobuchar (D-Minn.); South Bend, Ind., Mayor Pete Buttigieg; tech entrepreneur Andrew Yang; former congressman Beto O’Rourke (D-Tex.); and former Obama Cabinet official and former San Antonio mayor Julián Castro.

For the first time, all were on the same stage, which prompted several heated if still respectful skirmishes between Biden, Sanders and Warren. That may not be the case in October’s debate, which may stretch over two nights.

Get fact-checking and analysis here | A transcript of the debate so far

Health care served as an early, and testy, demonstration of intra-party feuds:

Biden, Warren and Sanders opened the debate with a clash over health care that was a proxy argument over the future of the Democratic Party. Warren and Sanders arguing that Medicare-for-all would save Americans money and Biden, joined by the more moderate candidates, made a case against a wholesale overhaul of the health-care insurance industry as too expensive and unpopular.

It was part of a broader divide onstage, between candidates who favor less sweeping but more attainable goals and those calling for huge structural change.

“How are we going to pay for it?” Biden asked, saying his idea of improving the Affordable Care Act was better than Medicare-for-all. “As far as my distinguished friend, the senator on my left (Warren) has not come forward and said how she’s going to pay for it. I lay out how I will pay for it, how I will get it done, and what we will do going forward.”

Warren declined to roll over: “And the answer is on Medicare-for-all, costs are going to go up for wealthier individuals and costs are going to go up for giant corporations. But for hard-working families across this country, costs are going to go down and that's how it should work under Medicare for All in our health care system,” she said.

Sanders returned to his argument that “greed and corruption” in the health care industry required the wholesale change of expanding Medicare coverage to all Americans.

“Every study done shows that Medicare for All is the most cost-effective approach to providing health care to every man, woman, and child in this country,” he said. “I, who wrote the damn bill, if I may say so, intend to eliminate all out-of-pocket expenses, all deductibles, all co-payments. Nobody in America will pay more than $200 a year for prescription drugs, because we're going to stand up to the greed and corruption and price-fixing of the pharmaceutical industry.”

[Read about their proposals]

The generation gap still smarts:

The ideological gap was not the only one threaded through out the debate. In perhaps its most breathtaking moment, Castro made a clear and repeated effort to point out Biden’s age and propensity for gaffes. During a back-and-forth over health care, Castro, 44, accused Biden, 76, of having had a memory lapse — a not-so-subtle swipe at the former vice president’s age.

“Are you forgetting already what you said two minutes ago?” Castro said, repeating the question three times within four sentences.

The problem for Castro: he was wrong. He was accusing Biden of saying his plan would not automatically enroll people in his public health care option. But what Biden actually said was that “anyone who can’t afford it gets automatically enrolled in the Medicare-type option we have.”

Castro, who engaged Biden as if his candidacy’s future depended on Thursday night – for him and other low-ranking candidates, it might – also brazenly suggested he was the rightful heir to Obama, in whose administration he also served.

“I’m fulfilling the legacy of Barack Obama, and you’re not,” he said.

Biden, without missing a beat, fired back: “That’d be a surprise to him.”

That drew some unanimous derision from the other candidates.

“Come on, guys,” said Yang.

“This is why presidential debates are becoming unwatchable,” said Buttigieg.

“Yeah, that's called the Democratic primary election, Pete,” Castro retorted. “That's called an election.”

Thursday’s debate was “a step in the right direction” for Democrats worried about how their favorite candidates might shape up in debates against President Trump, says politics reporter Aaron Blake.

The resurrection of Barack Obama:

The nation’s most popular Democrat found his legacy pummeled in the July debate in Detroit, a move that flabbergasted Democrats outside the circle of candidates and delighted Republicans who saw it as more evidence of the leftward lurch of their opponents. This time around, there was praise aplenty.

“I want to give credit first to Barack Obama for really bringing us this far,” Warren said during a health care discussion. “We would not be here if he had the courage, the talent or the will to see us this far.”

“We owe a debt of gratitude to President Barack Obama,” Castro said as he prepared to take on Biden. “Of course, I also worked for President Obama.”

Biden, however, was a stand-in for the criticisms candidates had earlier made of Obama. And when it came to immigration, he struggled to defend Obama’s legacy. Co-moderator Jorge Ramos asked Biden about the more than 3 million deportations that took place over Obama’s two terms in office. “Why should Latinos trust you?” Ramos asked.

Biden first said it was “outrageous” to compare the records of Trump and Obama on immigration. He then pointed to Obama’s efforts to find a pathway to citizenship for the millions of young people brought to the United States illegally as children.

“I’m proud to have served with him,” Biden said, before pivoting to attack Trump’s record and call for the reauthorization of the Violence Against Women Act.

Ramos pointed out that Biden hadn’t answered the question. “Did you make a mistake with those deportations?” he asked.

After Biden responded that Obama did the best he could, Ramos continued to press him: “How about you?”

“I’m the vice president of the United States,” Biden said, suggesting he lacked the power at the time.

That drew another sharp rejoinder from Castro, who reminded the crowd that he, too, served in the Obama administration.

“He wants to take credit for Obama’s work but not have to answer any questions,” he said of Biden.

Democratic divisions of the past are not really past:

The man Biden has lauded so often in his campaign, Obama, won the Democratic primaries of 2008 partly because of the break he represented from the party’s past positions. He had opposed the war in Iraq, whereas his rival Hillary Clinton had voted to give President George W. Bush authority to wage war. In a bit of turnabout, the man Clinton defeated in the 2016 primaries, Sanders, used that same vote against Biden.

“The truth is, the big mistake, the huge mistake, and one of the big differences between you and me, I never believed what Cheney and Bush said about Iraq,” Sanders said.

Biden appeared to acknowledge that distinction. “I should have never voted to give Bush the authority to go in and do what he said he was going to do,” he said.

But for most of the candidates, the foreign policy answers looked forward. Warren said she strongly supported bringing troops home from Afghanistan, but thought that military tools were not the only ones the United States should bring to bear.

“The problems in Afghanistan are not problems that can be solved by a military,” she said. “... We need to work with the rest of the world we need to use our economic tools we need to use our diplomatic tools we need to build with our allies, and we need to make the whole world safer, not keep troops bombing Afghanistan.”

Buttigieg, a veteran who served as an intelligence officer in the Navy reserves, said the United States should not have “an open-ended commitment of ground troops.”

Obama’s not a target, but President Trump is:

In her opening remarks, Harris directly took on the president -– who, as the debate kicked off, was addressing House Republicans at their retreat in Baltimore, and tossing some insults toward those on the Houston stage.

The only reason Trump hasn’t been indicted, Harris said, is because of long-standing Department of Justice guidance barring charges from being brought against a sitting president.

“And now, President Trump, you can go back to watching Fox News,” Harris said to burst of cheers as she wrapped up her remarks.

Sanders and Biden, too, took on Trump in their remarks, as did Klobuchar, who said the president “would rather lie than lead.”

Later, Buttigieg and other candidates mocked Trump on trade and his negotiations with China. Several pointed to the cost to American consumers of the trade war, while others slammed Trump’s actions as erratic.

“You know, when I first got into this race, I remember President Trump scoffed and said he'd like to see me make a deal with Xi Jinping,” Buttigieg said. “I’d like to see him make a deal with Xi Jinping.”

Gun violence generated plenty of emotion and some divisions between the candidates:

Since the last debate, mass shootings have killed dozens of Americans, and the subject remained raw and emotional — most notably for O’Rourke. Several candidates lauded O’Rourke for his public statements about gun control after a gunman last month killed 22 people at a Walmart in his hometown of El Paso.

O’Rourke used to routinely assure owners of assault weapons that he wouldn’t take their guns away if elected. But he said he had a change of heart in August, and he forcefully defended his proposal for a mandatory buyback of assault-style weapons.

“Hell yes, we are going to take away your AR 15, your AK 57,” O’Rourke said. “We’re not going to allow them to be used against your fellow Americans anymore.”

But while the candidates agreed on the need for stiffer gun control measures, they disagreed on how, exactly, to get those measures passed.

Biden argued that it was unconstitutional to take guns away from people via executive action, and that people who disagree should “speak to constitutional scholars, if in fact we could say, by the way, you can’t own the following weapons period.”

But Harris criticized him, saying his stance was too gloomy.

“I would say, Joe, ‘yes we can,’” she said, somewhat playfully using an old Obama slogan. Then she turned to Trump: “Look, obviously he didn’t pull the trigger, but he’s certainly been tweeting out the ammunition.”

Booker, who has introduced a gun licensing proposal, didn’t directly answer a question about how he would get that proposal passed, even when asked a follow-up question. “We get this done by having a more courageous empathy,” he said. Warren had a more concrete proposal: eliminating the legislative filibuster in the Senate that requires at least 60 votes to get anything done.

Tell us about your character:

Although the candidates have spent hours fileting their opponents’ records, voters may be more interested in matters of character. So when the moderators asked the candidates to describe what their biggest professional setback had been — and how they had dealt with it — they took the opportunity to talk in personal rather than professional terms. Biden spoke of the loss of his wife and daughter in the 1970s and his son in 2015 and recounted his struggle through grief.

“I learned that the way you deal with it is you deal with finding purpose, purpose in what you do,” he said. Then he turned his aim to the viewers. “But there's a lot of people been through a lot worse than I have who get up every single morning, put their feet one foot in front of another, without the help I had,” he said. “There are real heroes out there. Some real heroes.”

Warren spoke about losing her job as a special needs teacher when she became pregnant. She decided to go to law school, and then resumed her teaching career. “And the reason I'm standing here today is because I got back up, I fought back,” she said.

Buttigieg spoke of his decision to come out publicly as gay, despite facing a campaign for mayor in a conservative state.

“What happened was that, when I trusted voters to judge me based on the job that I did for them, they decided to trust me and re-elected me with 80 percent of the vote,” he said. “And what I learned was that trust can be reciprocated and that part of how you can win and deserve to win is to know what's worth more to you than winning.”

O’Rourke, however, did not talk about himself, returning poignantly to the El Paso shooting, and telling of his visit Wednesday with one of two coaches of a girls’ soccer team who were grievously wounded by gunfire.

“Those two men … their wives, they exemplify resilience to me,” he said. “And when we end this scourge of gun violence in this country, when we finally confront the racism that exists in America, when we’re defined not by our fears, but instead by our aspirations and our ambitions, it will be, in large part, I think, thanks to the example that El Paso has set.”