Sean Spicer served as communications director for the Republican National Committee during Donald Trump’s presidential campaign and as Trump’s White House press secretary until August 2017. His new book, “The Briefing: Politics, The Press, and The President” (Regnery Publishing), out Tuesday, addresses his bumpy tenure. Here, in adapted excerpts from the book, he reveals his inner thoughts and turmoil during two major media crises . . .

THE ‘ACCESS HOLLYWOOD’ SCANDAL

The second debate with Hillary Clinton was to take place on Sunday, Oct. 9, 2016, at Washington University in St. Louis.

As I took my seat on the plane flying from Reagan National Airport to St. Louis, Mo., my phone chimed. I had a message from [political operative] Katie Walsh.

We have a problem. Look at the e-mail I just sent you.

On the plane, as discretely as I could, I read a transcript Katie had flagged as urgent. It was not good. But it was a transcript, and perhaps it was inaccurate. Then came a second e-mail from Katie. There was a video that had been leaked to The Washington Post. The video had been recorded in 2005, and it captured a raunchy conversation between Donald Trump and Billy Bush, then host of “Access Hollywood,” in which Trump bragged that being a celebrity made it easy for him to seduce women, in rather graphic terms.

Katie called me. “Sean, this is huge. We need you to get back now.”

“Katie, if I get off this plane, I’m not getting to St. Louis. This is the last available flight before Sunday.”

She didn’t like it, but I stayed on the plane, stewing the whole way to St. Louis, unable to talk to anyone or do anything. The instant the plane hit the runway in St. Louis, I turned on my phone and saw that I had missed dozens of calls. For the rest of the day I was on the phone, nonstop, till sleep overtook me.

At first, we thought we were dealing with a dump of opposition research by the Democrats, but as events unfolded, it appeared that the “Access Hollywood” recording had been leaked by someone from NBC to The Washington Post.

Everyone at the RNC and in the Trump campaign knew that this video was our pivotal crisis. Trump had three options at that point. One was to curl up and die. The second was to do an apology tour. The third was to barrel through it and come out with all guns blazing. At this moment, the media couldn’t comprehend how Donald Trump could even dare to show his face in St. Louis, much less present a spirit of proud defiance. Most political operatives would opt for the apology route.

Didn’t Donald Trump know that it was all over?

But Trump read the national mood better than his critics. On Saturday, as I took calls from Republican committee members, donors, reporters, pundits and friends, I was surprised by how many women who contacted me did not consider Trump’s comments a big deal. One prominent Republican woman told me, “You all talk like this; we know it.” (Actually, we men don’t all talk like this, but I held my tongue.) Clearly there were a lot of detractors, but many people I spoke with didn’t think Trump’s vulgar remarks from 11 years ago were relevant or important.

As he often does, Trump moved forward when any other candidate would have been left for dead.

Trump succeeded by dismissing his remarks as “locker-room” talk — which many people apparently thought they were — and by pivoting against Hillary in a way that no other Republican candidate would have dared: Why should I be crucified for locker room talk when you protected your husband after he faced a credible allegation of rape?

Steve Bannon supported the candidate’s response by bringing a surprise to the debate. He invited Juanita Broaddrick, Kathleen Willey, Kathy Shelton and Paula Jones — women who had accused Bill Clinton of rape, groping and sexual harassment — as the campaign’s guests. Steve tried to keep their arrival secret (though, inevitably, rumors started leaking) lest someone in the campaign or the debate organization overrule him.

Then Steve did something no one saw coming. Prior to the start of the debate, he gathered the women and held a press conference in which they appeared with Donald Trump.

If anyone was unnerved by this turn of events after the release of the “Access Hollywood” tape, it wasn’t Trump. It was the Clintons. Hillary had to debate with these women staring her down from the audience. With this panel of women, Donald Trump had not only leveled the playing field, he had put Hillary on the defensive. Many people had to ask themselves: If what those women said is true, what kind of a woman would stand by a man who did such things? In the debate, Trump did not act chagrined or pull his punches. He did not even shake hands with Hillary. He was aggressive and pointed in his criticism. Hillary later said that Trump had made “her skin crawl” during the debate. The pivotal moment had arrived . . . and the pivot turned in Trump’s direction.

The media didn’t see it. David A. Graham, writing in The Atlantic under the headline “Donald Trump’s Disastrous Debate” declared, “With Republicans abandoning Trump in droves just 29 days before the election, Trump seemed content to drive all of them off . . .” While the “Access Hollywood” video had taken a temporary toll, the debate had provided an even bigger boost. Trump’s underdog campaign was in fact regaining its momentum.

In the third and final debate, in Las Vegas, Donald Trump employed another nontraditional tactic. The format required one candidate to stay seated while the other stood and took the floor. Donald Trump refused to sit still. He paced around while Hillary spoke, always staying in the frame behind her and towering over her. It was domineering and a little strange, but it worked. Everything she said was under the scowling face of Donald J. Trump. It was not something I would have thought of or advised. But Trump showed, once again, that he is a master at emotional imagery. The political playbook for debates had been thrown out the window and burned.

Throughout the primary and general debates, Donald Trump was like an inflatable ball in a swimming pool. Hillary Clinton and the media tried hard to keep him submerged, but he always popped back up to the surface. Nothing could sink him. And that fact caused quite a few media heads to explode.

“Relax,” The Nation assured its left-wing readers in a choice bit of graveyard whistling, “Donald Trump Can’t Win.”

“Trump won’t win,” a writer in the UK’s The Guardian declared, “In fact, the US could be on the brink of a liberal renaissance.”

Even some of our side’s own political gurus were not projecting a win. Karl Rove, no stranger to presidential politics, said on Fox News, “I don’t see it happening . . . If he plays an inside straight, he could get it, but I doubt he’s going to be able to play it.”

In making such predictions, the media and even some Republican loyalists didn’t see the power of Trump’s populism and message; they also misread “outside the Capital Beltway” voters. The smugness and rhetoric of the naysayers created an echo chamber that helped amplify the overconfidence of the Clinton campaign, the worst case of choosing the-Oval-Office-drapes-before-the-election since Thomas Dewey.

‘HITLER DIDN’T EVEN SINK TO USING CHEMICAL WEAPONS’

I have helped countless candidates, party officials and elected officials undergo media training.

And the No. 1 rule I gave every Republican was don’t ever, ever talk about rape or compare anything or anyone to Hitler or the Holocaust.

Ever.

On April 11, 2017, I violated my own number one rule.

Earlier, I had been part of a small, impromptu briefing in the dining room off the Oval Office where Defense Secretary James Mattis had explained to the president the degree of the current atrocities committed by Syria’s leader, Bashar al-Assad. He noted that not even Adolf Hitler had dared to use chemical weapons on the battlefield (note the word “battlefield”).

When I went into the briefing room to begin the daily briefing, echoes of Mattis’ words were still with me.

When I opened up the briefing for questions, 11 of the first 15 focused on Syria. I was doing well, talking about the president’s reaction and concern. But then came the 16th question.

“The alliance between Russia and Syria is a strong one; it goes back decades . . . What makes you think that at this point [Putin’s] going to pull back in his support for President Assad and for the Syrian government right now?”

I thought to myself, “I got this.” But instead of staying on the messages that had been working just fine, I tried to turn it up a notch:

“I think a couple things. You look — we didn’t use chemical weapons in World War II. You had someone as despicable as Hitler who didn’t even sink to using chemical weapons. So, you have to, if you’re Russia, ask yourself is this a country that you and a regime that you want to align yourself with? You have previously signed on to international agreements rightfully acknowledging that the use of chemical weapons should be out of bounds by every country. To not stand up to not only Assad, but your own word, should be troubling.”

I made a couple more points and thought I had sufficiently described the outrage we had toward both Assad and Russia. The questions in the briefing room are asked at the speed of light. I kept going, oblivious to the damage I had done.

The next question was about the president’s tax returns. Then came a question about the Easter Egg Roll. Nothing seemed out of the ordinary.

Then I called on ABC News’s Cecilia Vega.

“Sean, thanks. I just want to give you an opportunity to clarify something you said that seems to be gaining some traction right now.”

What now?

Then she started reading from her phone.

“ ‘Hitler didn’t even sink to the level of using chemical weapons.’ What did you mean by that?”

What? Frantically, I’m thinking, “What did I do?”

I responded, “I think when you come to sarin gas, there was no — he was not using the gas on his own people the same way that Assad is doing, I mean, there was clearly — I understand your point, thank you.”

Cecilia then tried to throw me lifeline white hNo. 2, which I failed to grab.

She said, “I’m just getting…” but I cut her off and stepped in it deeper and deeper.

I knew it was bad, but I still asked, how deep am I?

“Thank you, I appreciate that,” I said. “There was not — he brought them into the Holocaust center, I understand that. But I’m saying in the way that Assad used them, where he went into towns, dropped them down to innocent — into the middle of towns. It was brought — so the use of it — I appreciate the clarification there. That was not the intent.”

What had I done. Holocaust centers?

I didn’t realize until later that I had inadvertently omitted General Mattis’ important phrase “on the battlefield.”

The instincts that kick in behind that podium are similar, I imagine, to those of a quarterback facing a blitz — just get rid of the ball and don’t get knocked down. But after a bad play, a quarterback can call a timeout and get his thoughts together and confer with his team. A press secretary behind the podium doesn’t have any timeouts to call.

After the briefing, I went to my staff. I knew it was bad, but I still asked, how deep am I? They gave me a look that said, “Deeper than the Titanic.”

RNC Chair Reince Priebus came into my office.

“Remember the first thing you taught me in media training?” he asked.

“Yes,” I said sheepishly. Never compare anyone to Hitler.

I made a mistake, a big one, and I needed to say so.

I went to the Oval Office to see the president.

“Mr. President, I need you to know that I just stepped in it really badly, and I screwed up.”

“I saw it. But I know what you meant, Sean. It’s going to be OK.”

“Thank you, sir, but I think I’ve embarrassed you and the administration and insulted the Jewish people. I need to make it right.”

“Look, Sean, you screwed up, but I know what you meant. You clearly didn’t mean . . .” He trailed off. When he spoke again, his tone was gentle. At a moment when I felt my worst, he tried to reassure me and was gracious, caring and forgiving. Finally, he said, “Do what you think is right.”

In this moment, I knew I had three choices: one, do nothing and hope it blew over; two, look for a friendly interviewer or reporter and try to put my spin on the story; or three, find the most challenging interviewer I could, own the mistake, and ask for forgiveness. I chose number three.

I asked my team to check which news shows I could get on ASAP. They came back with several options, including appearing on CNN with Wolf Blitzer at 5 p.m. I knew from the outset that it wouldn’t be an easy interview. Wolf always asks tough questions. And he is the son of two Holocaust survivors.

“I was obviously trying to make a point about the heinous acts that Assad had made against his own people last week, using chemical weapons and gas,” I told Wolf. “Frankly, I mistakenly used an inappropriate and insensitive reference to the Holocaust, for which, frankly, there is no comparison. And for that I apologize.”

Wolf kept boring down on me. Wasn’t I aware that in addition to the Jews, others had been victims of Hitler’s poison-gas chambers?

Of course, I told him.

“Have you spoken to President Trump about your blunder today?” Wolf asked.

“Obviously, it was my blunder,” I said.

To think that I had offended people — especially those whose families had been victims of the Holocaust — twisted my stomach in a way I had never felt before and hope to never feel again.

That evening, I was as down as I ever was. Some people can shrug off bad moments, but I have a hard time forgiving myself when I make a mistake, especially when I hurt others. Fortunately, my wife, Rebecca, and the kids were waiting for me at home, and that made all the difference.

Marlin Fitzwater, who had served in both the Reagan and the George H.W. Bush communications shops, wrote me early in my days at the White House with a bit of sage advice: “You don’t have to explain what you don’t say.” His words would have served me well on that day.

Reprinted with permission from “The Briefing” by Sean Spicer, 2018, Regnery Publishing, Washington, DC. Copyright © 2018 Regnery Publishing part of Salem Media Group