Former national security adviser John Bolton said Tuesday that it may have been a “mistake” not to challenge President Trump more aggressively during his tenure at the White House but that he tried to focus on U.S. foreign policy rather than on Trump’s actions.

“I’m not an investigator,” Bolton said during a Washington Post Live event. “I had plenty of stuff to do. . . . I told other White House advisers of my concern [and] I tried to do my job.”

Bolton, who has come under intensifying criticism for his new book, “The Room Where It Happened,” said Americans have a misconception about the ability of White House advisers to challenge the president, suggesting such pushback may have been futile but he could not say for certain.

“Service in the White House is not like the ‘West Wing,’ ” he said, referring to the TV drama. “There aren’t dramatic confrontations with the president.”

“It’s easy from the outside to say that was wrong, and maybe it was a mistake,” Bolton added.

The lifelong Republican officially unveiled his 592-page memoir on Tuesday after a high-profile legal battle with the White House, and buzzworthy advanced excerpts ensured its place on bestseller lists.

Bolton’s book has achieved a rare feat in the Trump era: uniting a divided political system — against John Bolton.

The longstanding foreign-policy hawk has come under sustained attack from the president, who on Tuesday called him a “washed up Creepster” and a “lowlife.”

The White House has accused Bolton of publishing classified information and is seeking to force him to turn over the $2 million advance he received. A judge on Saturday rejected a request to block the sale of the book but said Bolton likely “jeopardized national security” and exposed himself to criminal prosecution.

Republicans in Congress have also impugned Bolton’s motives, with House Minority Leader Kevin McCarthy of California saying, “Money drives a lot of people to say a lot of things” and tweeting that the book “could jeopardize our national security. Appalling.”

Democrats, meanwhile, have expressed disgust at Bolton’s decision to wait until the publication of his book to reveal his allegation that the president’s wrongdoing went far beyond the scope of the House impeachment probe, which Bolton did not testify before.

“I don’t want to pay money for a book that was a substitute for testifying before Congress about the well-being of the American people,” House Speaker Nancy Pelosi (D-Calif.) said.

Bolton told The Post he entered the Trump administration hoping the then-ubiquitous stories of Trump’s chaotic and fickle management style were exaggerated, but he soon found out they were accurate.

Bolton said the “most disturbing moment in the early days” of his tenure was at the NATO summit in Brussels in 2018 when Trump “really was very close to withdrawing” from the alliance. Bolton said he, Secretary of State Mike Pompeo and then-Defense Secretary Jim Mattis did everything they could to prevent him from doing so.

“We all worked in various ways to help persuade the president not actually to withdraw,” he said. “That whole incident, which played out over a 48-hour period, was very unnerving to me.”

The book itself has spawned a media bonanza with pages upon pages of palace intrigue and detailed accounts of a rock-ribbed conservative expressing amazement at the president’s lack of knowledge about the world and willingness to break the law to protect himself in a pattern of actions that amounted to “obstruction of justice as a way of life,” Bolton wrote.

In the book, Bolton accuses Trump of being obsequious to authoritarian leaders and dictators, offering to lessen sanctions on the Chinese firm ZTE and the Turkish bank Halkbank to curry favor with Chinese President Xi Jinping and Turkish President Recep Tayyip Erdogan. Bolton says Trump approved of China’s jailing of more than 1 million Chinese Muslims in “reeducation camps” in Xinjiang and likened negotiating with North Korean leader Kim Jong Un to dating women — always wanting to break with the “girl” first rather than risk being dumped.

Democrats, such as Senate Minority Leader Charles E. Schumer of New York, described Trump’s actions in the book as “revolting” but said “I would have preferred Mr. Bolton to tell these stories under oath at the impeachment trial.”

On Tuesday, Bolton accused the Democrats of failing to build bipartisan consensus during the impeachment process, and because of that “partisan” quality, he did not think it would be worth it to jump “off the cliff” in service of their cause.

“If the goal was removing him from office, they did it in 180 degrees the wrong way,” said Bolton.

Some Democrats have said Bolton, whose conservative credentials are not in doubt, would have been the ideal witness for bringing conservatives into the fold.

In interviews since the book has come out, Bolton has called Trump unfit for office and said he should not be reelected, but Bolton ruled out voting for the presumptive Democratic presidential nominee Joe Biden.

“I’m going to figure out a conservative Republican to write in,” he said.