WASHINGTON — As America faces the seemingly unpopular choice of Donald Trump and Hillary Clinton, President Obama is looking better than he has since the start of his presidency, according to a new McClatchy-Marist Poll.

There are warning signs that the country could want a change in direction. Americans who are worried about the economy, political gridlock and terrorism think the country is going in the wrong direction by a rate of 70 to 25. But 51 percent of registered voters say they approve of the job Obama is doing as president, compared with 43 percent who disapprove.

Before this year, the last time more than half of the electorate gave Obama such high marks was in 2009, after he was first elected to the White House on a message of hope and change.

“I think President Obama has been extremely thoughtful as a president in a time of great change and conflict in our country,” said Marilyn Heiman, 54, a Democrat who works on natural resource issues in Seattle. “And he’s done it with very little drama.”

Obama’s approval rating slumped to 40 percent before the 2014 midterm elections, when candidates did not want to appear on the campaign trail with him, but his numbers have improved since caucuses and primaries for the 2016 presidential race got underway at the beginning of this year.

Lee Miringoff, director of the Marist Institute for Public Opinion in New York, which conducted the nationwide poll, said that’s in part because people are comparing him to Democrat Hillary Clinton and Republican Donald Trump.

Clinton and Trump are running close in the latest McClatchy-Marist poll, as they clash in a contest in which both sides have engaged in name-calling and negative campaigning. “The campaigns have been so divisive,” he said.

Miringoff said Obama’s numbers were the best thing that could have happened to Clinton’s campaign just weeks after he endorsed his former secretary of state, calling her possibly the most qualified person ever to run for president of the United States.

“It’s significant to the degree that Hillary Clinton is following him and then depending on him in her campaign,” he said.

By 90-6, Democrats approve of the job Obama is doing. Independents approve by 50-45. Not surprisingly, just 10 percent of Republicans approve of his work, while 84 percent disapprove.

Obama’s approval spans most regions of the country, ages and incomes. African-Americans gave the first black president the highest marks, 88 percent, followed by Latinos, 64 percent, and whites, 41 percent.

“I can’t say I’m against the guy,” said Mary Beth Koniak, 46, a Republican in Staunton, Ill., who works for Boeing. “You see everybody else hating on him, but you can’t stop the terrorists. You’re never going to be able to stop them. Obama hasn’t done anything wrong.”