WASHINGTON — For 30 seconds during the nail-biting climactic World Series game, millions of Americans saw President Trump portrayed as an effective leader tending the nation’s business — boosting the economy and keeping the country safe while Democrats were zealous partisans pursuing impeachment.

The depiction, complete with stirring music, came courtesy of Trump’s reelection campaign, airing its first national TV ad a year ahead of the 2020 election. Many Republicans and Democrats believe that message will help Trump survive almost-certain impeachment — because it worked 20 years ago for President Clinton.

He just has to stick to the script.

“There is no question that Bill Clinton really helped himself through impeachment by sticking to his job,” said David Gergen, an advisor to four presidents, including Clinton. “The Trump campaign’s emphasis on his work as president is the right message. The real challenge to a strategy that emphasizes his accomplishments is that he keeps getting in the way.”

Clinton doubled Head Start funding and balanced the budget during his own House impeachment fight in 1998. He avoided an impeachment conviction in the Senate, thanks to steady public support, and he left office in 2001 with a 64% approval rating.

Trump, whose approval ratings have been mired in the low 40s, now can tout the U.S. military raid last month in northwest Syria that left Islamic State leader Abu Bakr Baghdadi dead and the terrorist group in disarray. And he claimed credit Friday for record highs in the stock market a day after they had seesawed downward.

But those successes may prove an outlier for an impulsive, emboldened executive who has carried out a scattershot, unfocused response to impeachment. In the six weeks since House Speaker Nancy Pelosi (D-San Francisco) launched the impeachment inquiry, Trump has relished his reputation as a counterpuncher — but he often appeared flat-footed, fighting back seemingly alone.

Trump has complained that Republicans aren’t defending him ardently enough, while GOP allies in Congress have voiced concerns about dysfunction in the White House and what has appeared much of the time to be a one-man war room.

He has added to his difficulties by announcing and then backing down on a U.S. troop pullout from Syria, and by announcing and then backing down on a plan to host the Group of 7 international summit at one of his golf resorts. Both moves drew sharp rebukes from fellow Republicans.

“Clinton was able to focus on the job because he truly, deeply loved it,” said Paul Begala, who served as Clinton’s White House counselor. “He is a policy wonk, and losing himself in the details of child care or Head Start was therapy for him. I suspect Mr. Trump does not have the same passion for policy.”

Though Trump’s approach differs, it may prove just as successful. House Republicans voted unanimously Thursday against a resolution that allows for public impeachment-related hearings, though the measure passed anyway. More important, while several Republicans in the Senate have criticized Trump’s behavior, none has formally broken with him over impeachment, suggesting a likely acquittal if the Senate holds a trial.

Trump’s announcement on Oct. 27 of the special forces raid that resulted in Baghdadi’s death turned from a sober, prewritten statement about national security into a sprawling, grievance-laden soliloquy on national TV, potentially squandering a chance to show him focused on his job despite the rancor of impeachment.

Days earlier, several Republican senators had sat down for lunch with the president at the White House. Over plates of beef, they delivered an urgent, three-pointed message: Stop doing things to alienate GOP allies, keep the impeachment message focused on decrying an “unfair” process, and maintain some semblance of an agenda.

According to a person familiar with the conversation, the senators told the White House that Trump’s plan to host the G-7 at his financially troubled Doral golf resort, near Miami, would probably lead to an impeachment article for violating the Constitution’s emoluments clause, one that some said they might support. Shortly afterward, Trump reversed course and said he would hold the summit elsewhere.

After the lunch, Sen. Lindsey Graham (R-S.C.) returned to Capitol Hill, where he held a news conference and reminded reporters, and perhaps the president, of how Clinton’s White House had responded to what it viewed as a partisan and unwarranted impeachment led by Republicans.

“He had a team that was organized, had legal minds that could understand what was being said [in] the legal proceedings in question,” Graham said. “They were on message every day. President Clinton defended himself, but he never stopped being president.”

The public may not have liked Clinton’s behavior with a White House intern, but people believed that he was still able to do his job, said Graham, who was a congressman at the time.

“And as he governed during impeachment, I think that was probably the single best thing he did, quite frankly, to avoid” conviction in the Senate and removal from office, Graham said. “I’m hoping that will become the model here.”

The message, widely shared among Republicans, apparently was not well received at the White House. Shortly after his news conference, Graham tried to temper his implicit criticism. “I did not mean to leave some with the impression the White House needed to hire a new team to handle impeachment,” he tweeted. “My interactions with the White House were in regards to a more coordinated strategy dealing with impeachment.”

Unlike Trump, Clinton was somewhat receptive to criticism and appreciated the gravity of his political situation as the impeachment investigation advanced.

Robert Shrum, an unofficial advisor to Clinton on communication matters, recalled a private meeting in the Oval Office days after the first story broke of the president’s relationship with Monica Lewinsky. The annual State of the Union address was only a week away, and Shrum said Clinton appeared distracted during a Cabinet meeting.

“I’d known him since college and I said, ‘Can I see you for a minute?’ and we went into the Oval. I told him, ‘Eight days from now, you’re going to give this speech and the country’s going to decide if you should still be president.’ ”

After that, Shrum said, Clinton “was incredibly focused on the speech and he came out of it on an upswing…. He was incredibly disciplined during this whole period in terms of the way he reacted, the way they put together a defense team, and they kept the country running.”

Trump, by contrast, often appears consumed by the impeachment probe. Except for his family, none of his advisors apparently can deliver difficult messages, divert his attention from cable news or deter him from tweeting.

In the week after Pelosi launched the impeachment inquiry Sept. 24, Trump tweeted 250 times — the most prolific period of his presidency — mostly about impeachment. On a recent Saturday, he tweeted 59 times. During an Oval Office meeting with an outside advisor, Trump talked for 30 minutes about his hatred for CNN, according to a person familiar with the conversation.

“Clinton didn’t talk about impeachment much,” Begala said. “He mostly talked about his agenda — and he acted on it. Every day, Clinton reminded the American people that while the hyperpartisan Republicans were trying to impeach him, he was committed to making folks’ lives better.”

Trump has blasted “do-nothing Democrats” for trying to remove him from office, stating that he still wants to make progress on legislative priorities, including infrastructure and the revamped North American Free Trade Agreement. But little has happened.

And Chile’s cancellation of the planned Asia-Pacific Economic Cooperation summit, due to anti-government protests in Santiago, dashed Trump’s hopes of meeting Chinese President Xi Jinping this month to nail down an elusive U.S.-China trade deal, depriving the White House of another possible accomplishment.

Concerned about Trump’s lack of focus, his former advisor Stephen K. Bannon launched a “War Room: Impeachment” podcast last month, offering suggestions on strategy in an outside attempt to help the president improve his messaging.

After insisting a war room wasn’t necessary, the White House has tried building something of an organization to coordinate its response, starting morning strategy calls between White House aides and Republicans on Capitol Hill.

But daylight remains between Republicans, who have mostly complained about the Democrats’ impeachment process, and Trump, who wants allies to defend his actions — specifically, his asking Ukrainian President Volodymyr Zelensky for “a favor” during a July 25 phone call — as appropriate.

Senior White House officials are considering hiring a deputy press secretary to focus exclusively on impeachment. But it hasn’t happened yet, and Trump remains his own most vocal spokesman.

Press Secretary Stephanie Grisham has not held an on-record briefing since starting the job in July. On Thursday, after House Democrats passed the impeachment resolution, she blasted them for not “focusing on pressing issues that impact real families.”

On Friday, she argued again on Fox News that Democrats were overly focused on impeachment. But she made clear that Trump is focused on leading his own defense, not a team of aides or lawyers.

“He is the war room,” she said.

Times staff writer Jennifer Haberkorn contributed to this report.