Washington • Then-White House staff secretary Rob Porter was the gatekeeper to President Donald Trump, but more important, he served as a watchdog to halt “dangerous” decisions.

Porter, a former top aide to Sen. Orrin Hatch who resigned in February after allegations were unearthed of prior spousal abuse, stopped the flow of some documents to the Oval Office and pushed back on some of Trump’s incendiary impulses, according to the new book “Fear: Trump in the White House” by famed journalist Bob Woodward.

The author writes that Porter and White House economic adviser Gary Cohn helped stave off some of Trump’s attempts to end free-trade agreements, even to the point of stealing paper off the Resolute Desk so the president didn’t see them.

“A third of my job was trying to react to some of the really dangerous ideas that he had and try to give him reasons to believe that maybe they weren’t such good ideas,” Porter told an associate, according to the book.

“But slow-walking things or not taking things up to him, or telling him — rightly, not just as an excuse — but this needs to be vetted, or we need to do more process on this, or we don’t have legal counsel clearance — that happened 10 times more frequently than taking papers from his desk,” the book quotes Porter as saying. “It felt like we were walking along the edge of the cliff perpetually.”

Woodward’s book, which has faced a strong rebuke from the White House, paints several top aides within the Trump administration as working against the president, who often acts on instinct and distrusts his own advisers.

Porter, who graduated from Brigham Young University and Harvard and was a Rhodes Scholar, plays a key role in the book — he’s mentioned more than 200 times — mainly for his work to deflect some of Trump’s half-baked plans and coax him toward better policies.

There were days or weeks when the operation worked, Woodward writes.

“Other times, we would fall over the edge, and an action would be taken. It was like you were always walking right there on the edge,” Porter is quoted as saying.

On Tuesday, as Woodward’s book was publicly released, Porter issued a statement saying that the tome was “selective and often misleading” in how it discusses Trump and his administration.

Porter said it was his job to manage the flow of documents to the president and ensure they had been “properly vetted.”

“The suggestion that materials were ‘stolen’ from the president’s desk to prevent his signature misunderstands how the White House document review process works — and has worked for at least the last eight administrations,” Porter said in the statement to The Salt Lake Tribune.

The former staff secretary said it was his job to ensure relevant viewpoints were considered so the president could make the best decisions.

“Fulfilling this responsibility does not make someone part of a ‘resistance’ or mean they are seeking to ‘thwart’ the president’s agenda,” Porter said. “Quite the opposite.”

Trump, he said, invites a robust debate among aides and has confidence in his advisers, even when they disagree.

“And I sometimes did just that,” Porter said. “But in the end, President Trump is the one who decides, and he has shown himself more than capable of doing so.”

In his statement, Porter does not disavow any of the quotes attributed to him.

Porter, 40, left the White House after his two ex-wives came forward to say he physically or verbally abused them, with one revealing a photo of the black eye she said Porter gave her. He denied the allegations.

Before he left, though, he had an oversized role in the White House, with Trump at one point telling Porter that he should report to him directly and not to then-Chief of Staff Reince Priebus.

“Forget about Reince,” Trump reportedly said. “He’s like a little rat. He just scurries around. You don’t even have to pay any attention to him. Just come talk to me.”

Porter also took on a key goal of the White House on trade policy as senior advisers took divergent positions. He held court weekly with top officials trying to accomplish plans that sometimes came from Trump’s moods.

At some points, Woodward writes, Porter stood as a critical voice to temper the president’s whims.

“You don’t have authority,” he told the president in one meeting, when Trump demanded to have the United States immediately pull out of the North American Free Trade Agreement.

The president was insistent, though, and ordered Porter to draft language to exit the compact.

Porter enlisted Cohn for help to stop the move he saw as a trigger for an economic and foreign relations crisis.

“I can stop this,” Cohn said to Porter, according to the book. “I’ll just take the paper off his desk before I leave.” And he later took it.

“If he’s going to sign it, he’s going to need another piece of paper,” Cohn said.

“We’ll slow-walk that one too,” Porter promised.

Woodward — whose reporting with then-Washington Post colleague Carl Bernstein helped take down President Richard Nixon, and who has penned several deep-dive nonfiction books on presidents since — explores the paranoia that he says drives Trump’s White House.

In one anecdote, Trump is venting about the then-new special counsel investigation into Russia’s interference in the 2016 election and whether Trump’s team played any part in it.

“Everybody’s trying to get me,” the president told Porter, the book says. “It’s unfair. Now everybody’s saying I’m going to be impeached.”

What are the powers of a special counsel? Trump asked Porter.

Well, Porter said, they’re virtually unlimited.