According to Bob Woodward's book, then-Defense Secretary Mattis had slept in his clothes in case of a missile launch from North Korea and visited the nearby Washington National Cathedral to pray. Credit: AFP.

It was the sum of all fears — a reckless US president poking the leader of a rogue nuclear power, risking a nuclear war.

Unfortunately, it wasn’t a fictional adventure novel. This was all too real.

As North Korean leader Kim Jong Un continued to conduct missile and nuclear tests, Donald Trump warned the country of “fire and fury” if it threatened the US — alarming members of his own administration.

Such was the fear of looming war and mass destruction, that former Defense Secretary Jim Mattis slept in his clothes because of the North Korean threat, according to a new book from Bob Woodward.

According to Woodward’s “Rage,” which is scheduled for release on Sept. 15, US-North Korean relations were fragile, and the potential for nuclear war was on the mind of the president’s national security staff, Business Insider reported.

Pyongyang, North Korea’s capital, fired about two dozen missiles in 2017, including its highest-ever intercontinental ballistic missile, shortly after Trump took office.

The situation concerned Trump’s national security team, including Secretary of State Mike Pompeo, who said, “We never knew whether it was real or whether it was a bluff,” Business Insider reported.

Meanwhile, then-Defense Secretary Mattis, a retired four-star Marine Corps general, had slept in his clothes in case of a missile launch from North Korea and visited the nearby Washington National Cathedral to pray, according to CNN’s review of the book.

Mattis announced he was resigning from his position in December 2018. He cited disagreements with the president’s decision to withdraw US troops from Syria, an unpopular choice among senior military leadership and US allies at the time, Business Insider reported.

“Because you have the right to have a Secretary of Defense whose views are better aligned with yours on these and other subjects, I believe it is right for me to step down from my position,” Mattis wrote in his resignation letter.

For more than a year after his resignation, Mattis, like other retired military leaders, refrained from speaking out against the administration.

In June, however, he wrote a statement published in The Atlantic that criticized the administration’s controversial response to the Black Lives Matter protests, Business Insider reported.

At the time, people across the country were protesting the police killing of George Floyd in Minneapolis, prompting the Trump administration to threaten to deploy US combat troops to American cities.

“I have watched this week’s unfolding events, angry and appalled,” Mattis said in his statement.

“Donald Trump is the first president in my lifetime who does not try to unite the American people — does not even pretend to try. Instead, he tries to divide us,” Mattis added. “We are witnessing the consequences of three years of this deliberate effort. We are witnessing the consequences of three years without mature leadership.”

Woodward’s book adds to Mattis’ criticism of Trump, according to CNN. He’s quoted as saying the president is “dangerous” and taught the US’s adversaries “how to destroy America.”

According to the book, Mattis said he resigned after Trump’s move to pull out of Syria, “when I was basically directed to do something that I thought went beyond stupid to felony stupid.”

Woodward, an award-winning Washington Post journalist known for his work uncovering the Watergate scandal in 1972, has written numerous books about American presidents and their top advisers based on extensive interviews with insiders.