Vice President Pence and his team have huddled for hours with the Senate parliamentarian. They have studied historical examples of other vice presidents who have presided over election results.

And they have begun anticipating the ire of President Trump — likely to come in the form of angry tweets — in the aftermath of Wednesday’s certification of the electoral college vote count before a joint session of Congress.

The role of Pence, who will preside over the certification, is largely ceremonial, one of the few official duties of the vice president in his capacity as president of the Senate. But Trump’s continued and baseless insistence that he won the 2020 presidential election has thrust Pence into a vise between the Constitution he swore to uphold and the president he has promised his fealty.

Pence’s performance Wednesday in the Senate chamber will serve as a fitting coda for a vice president who — through a combination of deference, obsequiousness and studied self-effacement — has made navigating the whims and loyalty requirements of his mercurial boss a full-time pursuit.

Pence’s team views the vice president’s role as procedural and limited, not unlike an umpire calling balls and strikes but ultimately hemmed in by the rules of the game. Trump, meanwhile, has expressed a desire for Pence to use Wednesday’s session to overturn the election results and snatch victory from President-elect Joe Biden — a stunning subversion of democracy that Pence has no authority to carry out, even if he so desired.

“I hope Mike Pence comes through for us, I have to tell you,” Trump told a crowd at a rally Monday night in Dalton, Ga. “I hope that our great vice president — our great vice president — comes through for us. He’s a great guy. If he doesn’t come through, I won’t like him quite as much.”

In a tweet Tuesday, the president was even blunter, incorrectly claiming, “The Vice President has the power to reject fraudulently chosen electors.”

The president’s faulty belief that Pence can somehow overturn the election results is being fueled by agitators who are feeding Trump misinformation, said several people in touch with the president and the White House, who along with some others spoke on the condition of anonymity to discuss the relationship between Trump and Pence. The group includes Rudolph W. Giuliani, the president’s personal attorney; Peter Navarro, a top White House trade adviser; and Sidney Powell, a lawyer and Trump ally.

Few if any legal experts agree. Former appeals court judge J. Michael Luttig, who is close to Trump and Pence advisers, refuted the president’s claims Tuesday on Twitter.

“The only responsibility and power of the Vice President under the Constitution is to faithfully count the electoral college votes as they have been cast,” Luttig wrote. “The Constitution does not empower the Vice President to alter in any way the votes that have been cast, either by rejecting certain of them or otherwise.”

In addition to meeting with the Senate parliamentarian, Pence and his team have consulted other experts, and studied the Electoral Count Act of 1887 and the Constitution.

As he almost always does before major moments, Pence has met with Trump to discuss his plans for Wednesday, according to people familiar with their discussions. He and others have tried to explain to the president that his role is strictly ceremonial — reading aloud each state’s electoral votes and officiating any debate — and that he lacks the power to take substantive action, these people said.

During their weekly lunch Tuesday, Pence explicitly told Trump that he does not believe he has the authority to block the congressional certification of Biden’s electoral victory, according to a White House official. But Trump issued a statement later Tuesday denying the conversation, which was first reported by the New York Times, claiming “the Vice President and I are in total agreement that the Vice President has the power to act.”

Some advisers have proposed that Pence, while leading the Senate on Wednesday, make comments that allege irregularities while still certifying the results, in a bid to show Trump he is fighting and is supportive.

Presidential historian Michael Beschloss said the challenge for Pence is that he’s under tremendous pressure from Trump to take action Wednesday “that even Pence knows is not legal or historically justified — and by ‘even Pence,’ I mean someone who has gone along with his boss in almost every respect that I can see over the last four years.”

“One of the risks that Pence took in abetting and enabling almost everything Trump has done is that at some point Trump would ask him to go even beyond his own line,” Beschloss said. “And that may be exactly what’s happening, because if Pence does not do what Trump wants on Wednesday, Trump will hate him and threaten to make his life miserable.”

Pence has long been a faithful steward to Trump, displaying loyalty that often borders on subservience. A relative outsider to Trump’s inner circle, Pence earned the president’s trust by rarely disagreeing with him publicly, keeping his counsel private, and seeming impervious to the chaos and mendacity that have become hallmarks of the administration in which he serves.

Allies marvel that even in private, they have never seen Pence so much as raise an eyebrow at Trump’s dark antics — which include becoming only the third president ever to be impeached and so bungling the coronavirus pandemic that more than 350,000 Americans have died on his watch.

Pence has found himself in seemingly impossible situations before in his service to Trump. Early in the administration, Pence’s travels abroad were spent trying to translate for — but not apologize on behalf of — the president, who world leaders feared was intent on upending the post-World War II global order. And later, Trump named him to head the White House coronavirus task force, as it became clear that the pandemic was spiraling out of control.

This final role poses particular challenges. The president has spent the past two months falsely denying his electoral defeat, and allies say Pence risks becoming the latest casualty of a fickle leader who demands absolute loyalty but rarely returns it in kind. Trump’s decision to replace Attorney General William P. Barr, who largely did Trump’s bidding, in the final weeks of his presidency served as a reminder that everyone in Trump’s orbit is expendable, and it “freaked a lot of people out,” said one close adviser to the president.

Right now, the general feeling toward Pence among Trump allies is sympathy, said one Republican in frequent touch with the White House, who chortled and said, “Poor guy.”

Within Pence’s orbit, there is worry over how Trump might react once Biden and Vice President-elect Kamala D. Harris are certified as the victors. Pence’s team was not given advance notice of Trump’s Pence comments this week, and the vice president’s aides expect that Trump will be angry at his No. 2 after the electoral votes are certified.

Still, they expect that any rupture between the two men will not be permanent.

The president began privately griping about Pence when Arizona Gov. Doug Ducey, a Republican with whom Pence is close, certified his state’s electoral votes for Biden last month, according to a Trump adviser familiar with the president’s complaints. Trump was further irritated by an ad from the Lincoln Project, an anti-Trump group, portraying Pence as starting to distance himself from the president in the wake of his loss, said several people familiar with his thinking.

More recently, Trump was caught off guard by media reports explaining that at Pence’s request, the Justice Department had argued against a lawsuit filed by Trump supporters that sought to give the vice president more authority in the electoral certification process. A federal judge in Texas dismissed the suit Friday.

To Trump, it seemed as if “the vice president was working against something he was supportive of,” said the Trump adviser.

Two administration officials said the president was frustrated because he thought that Pence should be doing more to publicly push his view that the election was stolen and that Pence had given up too easily. A person familiar with Trump’s ire said the president largely blames Marc Short, Pence’s chief of staff, for the vice president’s rhetorical caution.

Short has told others that Pence’s language about the election has been deliberately careful and that the vice president did not want to echo some of Trump’s most incendiary claims.

Nonetheless, Short over the weekend released a statement on Pence’s behalf saying that the vice president “shares the concerns of millions of Americans about voter fraud and irregularities in the last election” and “welcomes the efforts of members of the House and Senate to use the authority they have under the law to raise objections and bring forward evidence” on Wednesday.

Speaking Monday in Milner, Ga., Pence struck a similar note. “I know we all got our doubts about the last election, and I want to assure you, I share the concerns of millions of Americans about voting irregularities,” he said. “And I promise you, come this Wednesday, we’ll have our day in Congress. We’ll hear the objections. We’ll hear the evidence.”

In 1969, after losing the 1968 election to Richard Nixon, Vice President Hubert Humphrey (D) declined to preside over the electoral certification. But in 1961, after losing the 1960 election to John F. Kennedy, Nixon, then the vice president, did certify the election results despite privately believing that there was serious evidence of cheating in two key states.

Beschloss recalled how at a Christmas party at his house that year, Nixon opened the door and almost immediately greeted a visitor with: “We won the election, but they stole it from us.”

“That is how angry and indignant Nixon was privately,” Beschloss said. “Nevertheless, the first week of January, he not only declares the election for Kennedy and Johnson but gives a nice little speech about how democracy works, and that was Nixon at his best.”

Similarly, after losing the presidential election to George W. Bush in 2000, after a recount in a single state that culminated with a Supreme Court decision, Vice President Al Gore wryly performed his duties as president of the Senate, stressing publicly and privately the importance of upholding democratic institutions.

“People would have understood if he just went back to Nashville and hid under a rock, but he played it out and he did the thing, and he went back to Washington and he presided over his own defeat, and he went to the inaugural,” said Mike Feldman, a senior adviser to Gore at the time who is now a co-chief executive of Finsbury Glover Hering.

Beyond trying to avoid Trump’s wrath, Pence — who is expected to run for president in 2024 — has his own political considerations. He and his wife have looked for homes in the Washington suburbs, and he has discussed writing a book.

In the final weeks of the Trump administration, Pence could help himself prepare for a post-White House future by performing well on some of the administration’s remaining tasks, from pushing through outstanding executive orders to orchestrating a seamless handoff of the coronavirus task force to the incoming Biden administration, said one outside White House adviser.

Still, in keeping with his most familiar and comfortable posture, Pence is likely to strive to put Trump ahead of himself. He scrapped plans for a final trip abroad in coming days.

“Vice President Pence has been loyal to the country, the Constitution and the president these last four years,” said Kellyanne Conway, a former senior White House official who is close to both men. “Anybody who is reading in 2024 political calculations into his role in the certification process on Wednesday doesn’t know him.”

Carol D. Leonnig contributed to this report.