President Trump speaks during a meeting with workers titled “Cutting the Red Tape, Unleashing Economic Freedom” in the Oval Office of the White House in October. (Jabin Botsford/The Washington Post)

President Trump lashed out Tuesday morning at threats from many directions, taking aim at the special counsel’s Russia inquiry, the Federal Reserve, social media companies and undocumented immigrants in tweets that spanned more than two hours.

Trump’s Twitter tirade — which included some false and questionable claims — comes as he faces increasing peril from the investigation of special counsel Robert S. Mueller III and remains in a standoff with Democrats in Congress over funding for his long-promised southern border wall that could prompt a partial government shutdown at midnight Friday.

Trump touched on both battles in his tweets — writing at one point that “the whole Russian Witch Hunt is a Fraud and a Hoax which should be ended immediately” — as well as several other events from recent days. He also took a shot at “Crooked Hillary,” a reference to Hillary Clinton, his Democratic rival in 2016.

The extended airing of grievances came just hours before Trump’s former national security adviser, Michael T. Flynn, was scheduled to be sentenced for lying to the FBI about his dealings with the Russian ambassador to the United States — a development Trump acknowledged by wishing him “good luck today in court.”

Earlier, Trump wrote that the “biggest outrage yet in the long, winding and highly conflicted Mueller Witch Hunt” was the deletion of text messages between former FBI agent Peter Strzok and former FBI lawyer Lisa Page, both of whom wrote negative things about him.

Trump’s tweet seemed to be misstating a Justice Department inspector general report. The report, released last week, detailed broad problems in the FBI’s retention of text messages and the extensive efforts of investigators to recover lost exchanges.

The report — contrary to an assertion by Trump that texts were “purposely and illegally deleted” — found “no evidence” that Strzok and Page had “attempted to circumvent” the FBI’s data-retention policies. The inspector general also wrote that “content of the text messages did not appear to be a factor” in whether and how they were retained.

The FBI has had a long-running problem with an automated system to retain messages, and the inspector general highlighted technical glitches.

It is true that thousands of texts between Page and Strzok were once missing, but the inspector general recovered them, including a key exchange in which Strzok told Page “we’ll stop” Trump from becoming president.

Those messages, though, already have been well-publicized and helped shape another inspector general report blasting Strzok and Page for bias. Strzok was removed from the special counsel team, and eventually the FBI, because of the messages, and Page left separately.

The inspector general did note that investigators could not recover any texts from the phones assigned to the two FBI officials for their work with Mueller because by the time investigators requested the devices, they had been reset in preparation for others to use them. The president, though, has not seemed to key in on that — instead focusing on messages the inspector general recovered.

On the heels of a new report this week that detailed Russia’s efforts to use every major social media platform to help elect him in 2016, Trump also complained Tuesday that Facebook, Twitter and Google were working against him.

Without citing evidence, he said that Twitter “has made it much more difficult for people to join @realDonaldTrump.”

“They have removed many names & greatly slowed the level and speed of increase. They have acknowledged-done NOTHING!” Trump wrote.

Trump also trained his ire on the Federal Reserve, where officials are widely expected to raise interest rates this week despite his public effort to dissuade the U.S. central bank from putting any brakes on the economy.

“I hope the people over at the Fed will read today’s Wall Street Journal Editorial before they make yet another mistake,” Trump wrote, referring to a piece that advocated for “a prudent pause in raising rates.”

Trump later referred to the fight over the U.S.-Mexico border wall, writing: “Illegal immigration costs the United States more than 200 Billion Dollars a year. How was this allowed to happen?”

The White House did not immediately respond to a request for Trump’s source on the cost. In the past, he has cited numbers from the Federation for American Immigration Reform, which seeks to reduce legal and illegal immigration.

A report issued last year by the group pegged total spending by federal, state and local government on undocumented immigrants at $134.9 billion. The report said that undocumented immigrants contribute nearly $19 billion in taxes, meaning their net cost to the country is about $116 billion.