In his last State of the Union address, President Obama took shots at Republican presidential candidates, expressed one of his "few regrets," and said he's "as confident as I have ever been that the state of our union is strong." (Sarah Parnass/The Washington Post)

President Obama focused Tuesday on the pessimism coursing through an electorate now preparing to replace him, recasting the campaign-trail anger as a simple fear of change and a growing danger to the country.

His last State of the Union address, which he promised would be short but stretched for nearly an hour, returned to themes he has highlighted before. His message underscored his faith that government can — and must — help unsettled citizens through a changing economy and culture. He said he believed that most Americans put country before party but that their voices were drowned out by Washington’s partisan politics.

On the eve of the first primary contests, Obama also struck a note of deep concern for a nation he has only a year left to govern. Although he argued against Republican claims of America’s economic and military decline, he acknowledged that his successor will inherit a political culture more divided than the one that existed when he took office amid deep recession and a pair of wars.

“It’s one of the few regrets of my presidency — that the rancor and suspicion between the parties has gotten worse instead of better,” he said. “There’s no doubt a president with the gifts of Lincoln or Roosevelt might have better bridged the divide, and I guarantee I’ll keep trying to be better so long as I hold this office.”

His remarks were echoed by South Carolina Gov. Nikki Haley, who, in the official Republican response, also sought to counter the vitriol that has flowed from GOP candidates — most especially from Donald Trump.

Obama’s admission came during the closing passage of a speech that started much like a traditional State of the Union, with a list of plans and priorities, but ended with a presidential assessment of the state of the nation’s character.

Much of his impassioned, rising rhetoric revisited initiatives that have struggled to take hold during his time in office, including his early effort to repair U.S. relations with the Islamic world. The rise of the Islamic State and the recent attacks in Paris and San Bernardino, Calif., have provoked sharp anti-Muslim statements on the campaign trail and acts of arson, vandalism and other violence across the country. Obama used his closing chapter to warn against anger and a politics that he said runs against American values.

“We live in a time of extraordinary change — change that’s reshaping the way we live, our planet and our place in the world,” he said. And that change and uncertainty, he said, have activated a particularly virulent strain in our politics. Without mentioning GOP front-runner Trump, Obama took aim at his often divisive message, including his call for a temporary ban on Muslim immigrants.

“When politicians insult Muslims, whether abroad or our fellow citizens, when a mosque is vandalized, or a kid bullied, that doesn’t make us safer,” Obama said. “That’s not telling it like it is. It’s just wrong. It diminishes us in the eyes of the world. It makes it harder to achieve our goals. It betrays who we are as a country.”

Haley, in her Republican response, was equally blunt, calling on Americans to show strength during “anxious times” and avoid “the siren call of the angriest voices.” In what was clearly a rebuke of Trump’s anti-immigrant statements, she spoke of herself as a proud daughter of Indian immigrants and said that “no one who is willing to work hard, abide by our laws and love our traditions should ever feel unwelcome in this country.”

Haley, like Obama, didn’t mention Trump by name, but she made clear that she wanted to distance her party from the billionaire and his heated rhetoric.

Much of Obama’s speech focused on the priorities that have consumed his presidency. He spoke of broadening economic opportunity for all Americans, spurring innovation, forging new alliances and negotiating with enemies.

He emphatically summed up the lessons he’s taken from 15 years of war in Iraq and Afghanistan, saying that America cannot “try to take over and rebuild every country that falls into crisis.”

“That’s not leadership; that’s a recipe for quagmire, spilling American blood and treasure that ultimately weakens us,” Obama said. “It’s the lesson of Vietnam, of Iraq — and we should have learned it by now.”

The president floated virtually no major new ideas beyond his call for a moonshot effort to cure cancer, a priority of Vice President Biden, whose son died of a brain tumor last year. “For the loved ones we’ve all lost, for the family we can still save, let’s make America the country that cures cancer once and for all,” Obama said.

His speech was primarily a discourse on the state of America’s politics, a theme he’s hit in virtually all of his past addresses.

“I will not give up on trying to change the tone of our politics,” he said early in his presidency, in his first official State of the Union.

In subsequent State of the Union speeches, Obama emphasized the positive, focusing on Americans’ common values and shared dreams. Last year, he assumed a more chiding tone. “Imagine if we broke out of these tired old patterns,” he told the lawmakers assembled in the House chamber. “Imagine if we did something different.”

This year, as he prepares to campaign for a Democrat to succeed him, Obama was reflective, worrying that too many Americans have lost faith in the country’s political system, believing it to be rigged against them.

For the first time in his presidency, Obama prominently took some of the blame, suggesting that one of his biggest regrets was his own failure to bridge partisan divides.

He outlined steps that he believed were necessary to fix America’s bitterly divided politics, including a halt to gerrymandered electoral districts. “We have to end the practice of drawing our congressional districts so that politicians can pick their voters,” he said.

And he called for new limits on fundraising so that “a handful of families and hidden interests can’t bankroll our elections.” He promised to press for reforms to make it easier for Americans to vote.

But the most essential changes he advocated can’t be achieved by new regulations or laws. Obama, a president whose love of country and Christian faith have been questioned by his political opponents, spoke of something less concrete and much harder to realize.

“Democracy does require basic bonds of trust between its citizens,” he said. “It doesn’t work if we think the people who disagree with us are all motivated by malice or that our political opponents are unpatriotic.”

He spoke of the need to compromise and cast aside “the most extreme voices” in the country’s democracy. Here, Obama seemed less certain about how to achieve those goals.

“We have to change the system to reflect our better selves,” he said.

He called on Americans to vote, speak out, and stand up for the weak and vulnerable in society. He pressed for people to stay “active in public life.”

Time and again, he spoke of the difficulty of achieving the change that he aspired to.

“What I’m asking for is hard,” he said in one moment.

“It won’t be easy,” he said a few minutes later.

His call for a “better politics,” he said, was inspired by people beyond the Beltway, often ignored in the country’s roiling political debates. In the final lines of his speech, Obama invoked them. They were new immigrants and factory workers, soldiers who sacrificed for their brothers in arms and an elderly woman who waited in line for hours to vote. Many were the sorts of people who populated Obama’s earlier State of the Union addresses.

“They’re out there, those voices,” he said. “They don’t get a lot of attention, nor do they seek it, but they are busy doing the work this country needs doing.”