President Obama on Thursday warned Democrats against adopting a “Tea Party mentality” that could lead to deep divisions within the party and harm its chances of winning national elections.

ADVERTISEMENT

“The thing Democrats have to guard against is going in the direction that the Republicans are much further along on, and that is this sense 'we are just going to get our way, and if we don’t, then we’ll cannibalize our own, kick them out and try again,' ” he said at a town-hall meeting with law students in Chicago.

In that scenario, Democrats could “stake out positions so extreme, they alienate the broad public,” Obama added. “I don’t see that being where the Democrats go, but it’s always something we have to pay attention to.”

Obama’s comments come amid a major dustup between Clinton and Sanders that has Democrats concerned about keeping their party unified.

Sanders on Wednesday accused Clinton of being not “qualified” to serve as president because of her willingness to use a super-PAC and support for the Iraq War and free trade agreements.

The president did not name Clinton or Sanders. But he offered a staunch defense of his incrementalist view of politics, which has sometimes come under fire from the Vermont senator.

"That’s how change generally happens,” he said, citing the example of his signature healthcare law.

“It’s not perfect. There is no public option, not single-payer,” he said. “If I was designing a system from scratch, it would have been more elegant. But that’s not what was possible in our democracy."

The president also sought to downplay the divisions between Clinton and Sanders.

He said the debate among Democrats is “is a little bit more about means, less about ends,” noting that both candidates broadly agree on issues like the need for universal healthcare and combating climate change.

Obama said he understood the populist sentiment that has driven Sanders’s candidacy. But he said the answer is not to abandon a compromise approach.

“The danger, whether for Democrats or Republicans, is in a closed-loop system where everybody is just listening to the people who agree with them,” he said.

“And that anybody who suggests there is another point of view ... well, then you must be a sellout or you must be corrupted or you must be on the take or what have you," he added. "That is not, I think, useful.”

Obama could be a unifying figure for Democrats in this fall's election.

His approval ratings are at 50 percent or higher in most opinion polls, making him the most popular figure in his party.

But the ongoing primary battle has kept Obama officially off the campaign trail, though he has used his bully pulpit to go after Trump and other GOP candidates.

In speaking to Democrats, the president played the role of party elder. He said has seen this type of mentality bubbling up among Democrats throughout his presidency and is well versed in home harmful it can be.

“A lot of Democrats supported me and still support me got frustrated is because a bunch of the country doesn’t agree with me or them and they have votes too. And they elect members of Congress. That’s how our democracy works," Obama said.

“If you don’t get everything you want, it’s not always because the person you elected sold you out," he continued. "It may just be because in our system, you end up taking half loaves."

Obama was speaking at an event at the University of Chicago Law School where he urged Senate Republicans to take up the nomination of his Supreme Court nominee, Merrick Garland.

- Updated at 5:38 p.m.