With two weeks left before the close of voting, President Trump flew to the far northwest corner of Pennsylvania for a large rally where he aired grievances against the news media, complained that the pandemic had damaged his campaign and portrayed Democrats as purveyors of drugs and crime — all as a sea of loyal supporters in red MAGA hats cheered him on.

While Trump on Tuesday appealed in person to his most ardent fans with divisive themes, Joe Biden’s campaign beamed in to the nation’s living rooms during the World Series with a much broader audience in mind. “There is only one America. No Democratic rivers, no Republican mountains,” the actor Sam Elliott intoned as he narrated a commercial for Biden in his signature gravelly voice. Biden, meanwhile, was at home as the ad aired, eschewing public events to prepare for Thursday’s debate.

The split screen underlined the starkly different strategies Trump and Biden have deployed in the final stage of the presidential race. Trump has been spending heaps of cash staging crowded rallies designed to motivate his most fervent fans, despite the advice of public health officials to avoid large gatherings. Biden, who is leading in the polls, has been holding smaller, less expensive events and investing aggressively in television ads and virtual gatherings designed to persuade a wide audience that he can unify a divided country.

The divergent approaches reflect the thinking on each side. Biden campaign officials say they feel strongly about running a campaign safely — and their posture underscores their belief that Trump’s widely criticized handling of the pandemic is the decisive issue in the election. Any contrast with him — either in policy proposals or campaign practices — will benefit Biden, they feel.

The coronavirus pandemic has prompted the Biden campaign to experiment with different strategies, including some that could prove useful in a post-coronavirus world and mark a potential shift in the way campaigns are conducted.

Among its approaches, campaign officials have used trucks as mobile offices at which voters can pick up literature and yard signs without entering a building, and they’ve also set up drive-through pickups. Jenn Ridder, states director for the Biden campaign, said these tactics could be helpful in rural areas during future campaigns. Ridder said she also has found that engaging people in virtual events often leads to them volunteering to make phone calls or conduct other outreach later on.

“It’s taken a little bit more proactiveness on us to track these people down and suck them into the campaign, rather than just a big rally at the park where people show up and you just sign them up right there,” Ridder said. “It’s been a little more work.”

Trump, meanwhile, has been determined to project strength during a crisis, which he often does by flouting the advice health of experts and basking in the support of his most ardent fans.

Still, the main reason his campaign continues to hold large rallies is that the president loves them, aides said. They say Trump feels that when people see big crowds, they will be more inclined to vote for him. When his advisers argued against rallies, saying the events wouldn’t be safe, and instead going to smaller events designed to target certain groups, Trump insisted on returning to his signature format.

The differences between the campaigns came into sharp focus in the campaign finance reports released this week; they revealed a wide disparity in spending on travel, in-person events and use of virtual platforms from June to September, according to a Washington Post analysis.

The Trump campaign and two affiliated committees outspent Biden and his affiliates by more than 8 to 1 in event staging, facility rental and various fees, the analysis shows. The Trump side spent $17.6 million, compared with $2.1 million spent by Biden and his allies.

The Trump side also spent $7.1 million on transportation, including $1.8 million to reimburse the Treasury Department for using Air Force One, which doubles as Trump’s rally backdrop, to fly to campaign stops. Biden spent $3.6 million on travel and transportation, including $265,000 to lease an Amtrak train for a ­whistle-stop tour in Ohio and Pennsylvania the day after the first debate.

Meanwhile, Biden also spent more than $37,000 on communication services provided by Zoom, the platform frequently used by the campaign for its virtual events. Trump spent just $143 in Zoom subscription fees.

Trump has paid a host of high costs related to rallies and fundraisers in recent months, including $117,333 to a linen rental company, $221,020 to a biometric testing company and $47,506 to a sommelier services company.

By contrast, some of Biden’s biggest expenses for event production went toward companies that produce digital events. In September alone, Biden paid about $330,000 to a company named 090 Media, which specializes in live-streamed events. From July through September, he paid $535,651 to Wizard Studios, which stages socially distanced campaign events for Biden, including setting up “social circles” that allow guests, campaign staffers and reporters to maintain safe distances from one another.

Although Biden stepped up his travel in recent weeks, the past few days have marked a return to his pre-Labor Day pace. As Biden hunkered down Wednesday and prepared for the debate — his third day in a row without an in-person campaign event — Trump traveled to North Carolina for another rally. The Democrat aired a second World Series ad.

Biden’s absence from the trail was filled by a very prominent pinch hitter: Barack Obama stumped for him in Philadelphia. In his debut on the physical campaign trail for Biden, Obama talked about the importance of voting, and he sharply criticized Trump.

The 44th president was one of many surrogates on whom the Biden campaign has relied. On Wednesday, the campaign planned to host a virtual gathering of Colorado voters with the cast of “Grey’s Anatomy.” The campaign held a similar event aimed at Arizona voters featuring the comedian George Lopez.

Biden’s in-person gatherings are always small. Temperatures are taken, masks are worn and social distancing is enforced. One campaign official recalled an event with Sen. Bernie Sanders (I-Vt.) where students stood inside hula hoops to ensure safe spacing.

But the campaign also has had the benefit of a torrent of money. Biden started October with nearly three times as much cash on hand as Trump had, thanks to a surge of donations motivated by an urgent desire to defeat the president. Biden’s campaign entered October with $177 million, compared with Trump’s $63 million.

Raising money from wealthy donors also has become a more efficient endeavor for the campaign, which holds finance events virtually because of the pandemic, sparing the usual expenses such as a catering and entertainment.

On Tuesday, Sen. Kamala D. Harris (Calif.) held back-to-back virtual fundraisers as Biden’s running mate, events featuring actors such as Scarlett Johansson, Don Cheadle and Paul Rudd, as well as Golden State Warriors head coach Steve Kerr.

But Trump is committed to a different approach. He is still holding in-person fundraisers, including one planned for Nashville on Thursday ahead of the debate; tickets for that fundraiser are going for up to $250,000.

Aides say that beyond basking in adulation, Trump has a goal in resurrecting rallies: to drive up voter turnout and collect voter data, attract attention from local news outlets and draw a contrast with Biden’s more modest schedule. Tim Murtaugh, a campaign spokesman, said many of the attendees at the rallies are not registered Republicans or Trump voters.

But often, Trump attracts attention for reasons having little to do with the economy or other issues his aides and allies would prefer to see him emphasize. During his rally in Erie, Pa., on Tuesday night, Trump took yet another shot at Lesley Stahl of “60 Minutes,” played selectively edited clips of Biden on a giant screen and suggested that the only reason he was back in Erie — which is in a county he won narrowly in 2016 — was that his political standing has slipped during the pandemic.

“Before the plague came in, I had it made. I wasn’t coming to Erie. I have to be honest. There was no way I was coming. I didn’t have to,” he said. In reality, polls showed the president was likely to face a challenging race even before the outbreak.

Even the Trump campaign, however, relied on television and Internet ads for its biggest outlay, as did Biden. The Trump campaign and its affiliates paid more than $423 million from June through September to American Made Media Consultants for ad placements.

Meanwhile, the Biden campaign leaned on two major media-buying firms during those months, Media Buying & Analytics (which was paid $270 million) and GMMB (which was paid $137 million). The campaign also directly paid Facebook $27.8 million and Google $3.4 million for ads, filings show.

Even as the pandemic worsened, Trump and his team spent huge sums. Corey Lewandowski, an informal adviser, has bragged to others about how elaborate the stages were at various Trump events. Some of the campaign’s expenses — such as $500,000 worth of fireworks over the White House, a Super Bowl ad, and banners flown over the shorelines of beach towns — were seen as unnecessary by some in the campaign.

The campaign also has continued to spend money on family salaries and for office space in Trump Tower in New York, where the president no longer goes.

In recent weeks, however, the campaign has limited many of its trips to using a smaller Air Force One in a bid to save money. The campaign is charged by the seat, and the number of aides has been limited on the trips. Aides also have cut some television reservations, including in competitive states.

Trump campaign manager Bill Stepien has complained to others that when he took the reins of the campaign, there was not a formalized budget and he did not realize what a dire situation he was in, according to four people who have spoken to him.

“There’s no doubt the previous regime wasted a fortune. That money could have been far better spent. The president’s campaign is in worse shape now than it would be otherwise,” said Mike DuHaime, a Republican strategist who is close to Stepien.

But none of that was evident when Trump set off Wednesday for yet another rally at which thousands would cheer for him.

“Hello, everybody,” he told reporters on the South Lawn of the White House. “So we’re going to North Carolina. Big crowd. Really big crowd. And we’re going to have a good time.”

Felicia Sonmez contributed to this report.