WASHINGTON — President Donald Trump tried to shrug off one of the rockiest presidential starts in recent history by returning Thursday to familiar territory: a public appearance in which he was at turns combative, aggrieved, funny and nostalgic for the spontaneous give-and-take that characterized his campaign.

“I turn on the TV, open the newspapers, and I see stories of chaos, chaos, yet it is the exact opposite,” Trump said from the White House during a news conference. “This administration is running like a fine-tuned machine.”

Trump insisted that all of his early setbacks were the fault of others, the product of “fake news” reporting or both. “I inherited a mess,” he said. “It’s a mess at home and abroad.”

For well over an hour, he deflected and hedged about whether his campaign staff was in contact with Russian government officials before his election, saying that “nobody I know of” had and that he personally had no business involvements with the country.

Trump defended his ousted national security adviser, Michael Flynn, saying Flynn acted appropriately in discussing sanctions with Russia during the transition but was asked to resign because he misled Vice President Mike Pence about those contacts.

Retired Vice Admiral Robert Harward turned down Trump’s offer for that job Thursday, largely because of family concerns, according to a White House official who would not be named because Harward’s decision had not been publicly announced.

At his news conference, Trump continued to complain about a federal appeals court’s decision to block his temporary ban on travelers from seven Muslim-majority countries, while promising to issue a new order next week that he vowed would withstand judicial scrutiny.

Aides said Trump had been frustrated that his message was not getting through to the public. So the president and held the news conference, which was announced less than two hours beforehand. It was his first solo news conference since becoming president.

Unlike previous sessions, in which he almost exclusively took questions from news outlets considered friendly by the administration, this time he mixed things up directly with several of the mainstream media outlets he loves to denounce — and to diligently follow.

Trump has not fully adjusted from his freewheeling campaign, where he had an unquestioned enemy in Hillary Clinton, no federal bureaucracy to combat and the freedom to avoid domestic and foreign problems that were tricky or did not interest him.

His White House staff remains thin, decentralized and plagued by leaks and infighting.

His legislative agenda has confused many would-be allies in Congress. And the early forced resignation of Flynn has prompted bipartisan calls for investigations about his presidential campaign’s ties to Russia.

“I fired him because of what he said to Mike Pence — very simple,” Trump said.

“It certainly would have been OK with me” if Flynn discussed sanctions with Russian Ambassador Sergey Kislyak when President Obama was still in office, Trump said.

“I didn’t direct him, but I would have directed him because that’s his job,” Trump said.

Flynn’s discussion of sanctions while another administration was still setting U.S. policy was seen by many people outside Trump’s circle as inappropriate, and possibly illegal.

Trump repeatedly denounced the leakers in the government who have fueled the stories about Flynn, Russia and his sometimes quarrelsome calls with foreign allies. But he maintained that the stories themselves were “fake news.”

“The leaks are absolutely real. The news is fake,” he said.

Trump conceded that his problem with the media was often more in the delivery than the facts, though he did dispute several aspects of a New York Times report about his campaign’s contacts with Russia.

“The tone is such hatred,” he said. “I’m really not a bad person, by the way. No, but the tone is such — I do get good ratings, you have to admit that — the tone is such hatred.”

Trump boasted falsely about the size of his electoral victory, then told a reporter who carefully corrected him that he got the number from someone else.

He spoke enthusiastically about the crowds at his campaign rallies, publicly relishing the one he has scheduled for Saturday in Florida.

“I heard — just heard that the crowds are massive that want to be there,” he said.

There were also awkward moments, such as when he responded to an African-American reporter’s question about the Congressional Black Caucus by asking whether caucus members were “friends of yours” and if the reporter, April Ryan, wanted to arrange a meeting with caucus members.

Trump’s attacks on the media and repeated mentions of his defeated Democratic opponent Hillary Clinton — he said “Hillary” 12 times — could help rally his supporters.

Three-quarters of Americans either strongly approve or strongly disapprove of Trump, the nonpartisan Pew Research Center found in a survey released Thursday.

Overall, the survey, which was conducted last Tuesday through Sunday, found that 56 percent of Americans disapproved of Trump’s performance in office and 39 percent approved.

That’s similar to several other recent polls, although it differs from the poll by Rasmussen, a Republican favorite, which Trump cited.

That survey found 55 percent of Americans approving of Trump’s performance in office.

While some Republicans watch Trump’s unfolding tenure with increasing trepidation, some of his earliest backers in Congress told him Thursday that their constituents like what they see from the administration.

“In our district, his approval rating is through the roof,” Rep. Chris Collins, a New York Republican and leader of what he called the “Trump caucus” in the House, later told reporters.

“His supporters know that he’s delivering.”

Trump offered his own assessment about 90 minutes after the day’s main public event. “We had an exciting news conference before,” he said while signing a resolution overturning an Obama-era regulation on the coal industry.

“Some people loved it. I think nobody hated it. But I think it was very productive.”

The Associated Press contributed to this article.