President Biden and Donald Trump are on track to be the oldest pair of presidential nominees in U.S. history. They also are staring at what could become the longest general-election campaign ever.

If Trump locks up the Republican nomination soon, the two men will face a marathon one-on-one race to the Nov. 5 general election. Such an endurance test threatens to bring headaches for both candidates and their campaign staffers—and for voters who have said they dread a rematch of the 2020 race.

Biden, 81 years old, and Trump, 77, both like to sleep in their own beds at night. Both, too, are prone to errors and will be under the spotlight many months. Their campaigns will need to figure out how to pace them through such a long slog, while also adjusting how they raise and spend money.

In recent days, both Biden and Trump have made flubs that drew attention to their age. During a recent White House event, Biden mixed up two of his cabinet secretaries, confusing Homeland Security chief Alejandro Mayorkas and Health and Human Services Secretary Xavier Becerra.

In New Hampshire last week, Trump mixed up Nikki Haley, who continues to challenge him for the nomination, and former House Speaker Nancy Pelosi, delivering an extended riff in which he blamed Haley for failing to secure the U.S. Capitol during the Jan. 6, 2021, assault that he has been accused of instigating.

Trump’s back-to-back wins in the New Hampshire primary and Iowa caucuses made the head-to-head matchup appear inevitable. Although Haley has vowed to stay in the race, she faces such long odds in beating Trump that both parties are already treating the contest like a general-election campaign.

This never happens as early as January. Even in the history of fast marches to the nomination, such as in 1996 and 2000, a competitive primary diverted at least one front-runner’s attention as late as March.

The lengthy rematch will test the stamina of the two nominees, redistribute the spending of campaign money and eat into the space for deal making on Capitol Hill. Hundreds of millions of advertising dollars are expected to pour into roughly a half dozen swing states likely to determine the election. Both sides are hitting up donors to fund the protracted race.

Some voters already are weary.

“I want to get up every day, I’d like to see the news, have my cup of coffee—there are a lot of people like me—and you can’t do it because all of it is about the fighting back and forth,” said Alan Leo, 68, a retired food-industry worker from Waterville Valley, N.H., who spent the last couple of months knocking on doors and putting up signs for Haley.

Leo, who voted for Trump twice, said he can’t support the presumptive Republican nominee this time and won’t vote in a Biden-Trump rematch. “For me there are no choices,” he said.

The campaign also is unusual for pitting a current president against a former one, meaning neither will require any introduction to the American people. For Trump, that includes his distinction as the first former U.S. president charged with federal crimes. He faces 91 charges tied to his handling of classified documents and efforts to overturn the 2020 presidential election.

Biden’s team aims to remind American voters of what they disliked about his first term in office and why they voted him out. They have long believed that the president’s lackluster poll numbers will improve once voters focus on the drama and chaos that surrounded Trump and his decision to cling to power after the 2020 election.

Biden’s team notes that many of the voters they have identified as persuadable didn’t believe there would be a rematch between the two men. With such a contest looming, the president has started attacking Trump more directly. The campaign is highlighting comments Trump made suggesting he would govern like a dictator on his first day in office, and arguing that Trump would further threaten abortion rights.

Trump and his team intend to ask voters to recall the prepandemic economy, when the cost of borrowing money was low and gas was less expensive. Trump contends that the world felt more stable back then, with Russia’s armies quiet and the Middle East less volatile.

Inflation spiked after Biden took office, but has since eased, while wages have risen amid a tight labor market. Stocks have hit record highs this year.

Trump, who has focused more on Biden during his most recent events, will make a general election case that Democrats are soft on the border, allowing illegal immigration and the flow of fentanyl. When Biden was asked recently whether the border is secure, he responded: “No, it’s not,” and pushed Republicans to agree to an overhaul he is proposing.

Trump’s aides acknowledge his various trials will make scheduling difficult and could take him off the trail. So far, Trump has incorporated the court proceedings into his campaign, using them to fire up supporters with unsubstantiated claims that Biden is orchestrating the charges.

It will be weeks before either candidate has won enough delegates to officially clinch their party’s nomination. The first official Democratic primary contest is in South Carolina on Feb. 3. Both teams are likely to have the delegates necessary by March.

Most national polls taken in recent weeks give Trump an edge over Biden, or show the two running even.

A Reuters/Ipsos poll released Thursday showed Trump leading Biden by 6 percentage points, 40% to 34%. Some 70% of those surveyed, including roughly half of Democrats, said they agreed Biden shouldn’t seek re-election. Fifty-six percent, including about a third of Republicans, said Trump shouldn’t run. Three-quarters of respondents agreed Biden is too old to work in government; half said that of Trump.

The shift toward a general election this past week was felt on Capitol Hill, where Senate Minority Leader Mitch McConnell (R., Ky.) said privately to other Republicans on Wednesday that the politics have changed on reaching a deal with the White House to overhaul the country’s immigration system.

McConnell said he is loath to do anything to hurt the chances of his party’s standard-bearer, an acknowledgment that his fellow GOP senators are in a quandary given that some Republicans don’t want to impair Trump’s ability to run on the crisis at the border.

The border deal, which Republicans have made a condition for approving more aid for Ukraine in its war against Russia, is one of a long list of unfinished items in Congress. Lawmakers still haven’t agreed on full-year spending plans and could force a partial federal government shutdown in coming weeks.

Both candidates have aged noticeably since the last campaign. That contest required less stamina because the Covid-19 pandemic reduced in-person events for Biden, although Trump held rallies, particularly in the closing days of the campaign.

Biden’s doctor has pointed out that the president’s gait has stiffened, something he attributes to age-related changes to the spine. Biden sometimes wears sneakers with his suits, and he started using a smaller staircase to board Air Force Once to minimize the risk of tripping. He quips about his age, while noting that it brings wisdom.

After an earlier version of this story was published, Kevin Munoz, a Biden campaign spokesman, said the president’s long career and experience “have helped him deliver on the very popular legislative achievements he is running for re-election on and have propelled Democratic wins up and down the ballot.”

Trump has drawn attention to his own physique. In December, while attending a court hearing, Trump saw a sketch drawing of himself and told the artist, “I gotta lose some weight.” He tells audiences he “aced” a cognitive test.

Biden already has visited North Carolina, Pennsylvania and Wisconsin—three of seven states where the general election is expected to be decided. He is using major speeches on protecting democracy and abortion rights to highlight the themes of his campaign or reach key voting blocs. He also is doing small events that the campaign is repackaging for social media.

During a recent stop in Raleigh, N.C., he visited a modest home for a nearly two-hour discussion with a family who benefited from his efforts to cancel student loans. Afterward, one of the family members posted a video of Biden’s visit on TikTok. It has been viewed 3.7 million times, exceeding the reach of many cable news programs.

Trump, known for his megarallies, is mixing in smaller events in hotel ballrooms. They give him media exposure but are less expensive than rallies, which can cost up to $250,000 apiece.

Both candidates are expected to use surrogates to campaign. One group Biden is turning to is Democratic governors. There are just 11 gubernatorial contests this year, and no Democratic incumbent is up for re-election, which frees them up to travel for the president without concerns about how it will affect their local standing.

Some of them, including Michigan Gov. Gretchen Whitmer, North Carolina Gov. Roy Cooper, California Gov. Gavin Newsom, Illinois Gov. J.B. Pritzker and Minnesota Gov. Tim Walz, harbor their own presidential ambitions, giving them an incentive to crisscross the country and build their brands.

In the primaries, Trump surrogates have included his son Donald Trump Jr., Reps. Matt Gaetz of Florida and Marjorie Taylor Greene of Georgia, and Sen. J.D. Vance of Ohio. The campaign plans to use them in general election battlegrounds. Recently, he turned to some of his former challengers for the nomination, including Sen. Tim Scott of South Carolina and biotech company founder Vivek Ramaswamy.

Haley’s refusal to abandon the race is creating what is at least a short-term distraction for Trump. She has said that only a sliver of the nation’s Republicans have weighed in so far and that she intends to compete at least through her home state’s Feb. 24 nominating contest, where Trump leads her by 38 percentage points, according to a polling average.

Should she drop out sooner, it would hurt local television advertising in markets in states with later primaries. “Without a doubt, this primary season is shaping up to be a real disappointment for local stations in key states,” said Michael Nathanson, an analyst at media-research firm MoffettNathanson.

Even so, the industry has predicted the election cycle will be the most expensive ever, fueled in part by the highly contested presidential race and the fight for Congress.

Spending on political ads is expected to jump to $10.2 billion for the 2023-24 election cycle, up 13% from 2019-20, AdImpact said. Despite the growing dominance of digital advertising, broadcast TV continues to be the go-to medium for candidates and is expected to account for about half of all election ad expenditures, the ad-tracking-firm said.

A shortened primary race could shift the focus of presidential spending toward general-election swing states, said John Link, vice president of data at AdImpact.

“There is one benefit to general presidential advertising starting early,” said Steve Lanzano, chief executive officer of TVB, a trade group that represents the local broadcast TV industry. “It often means the candidates advertise across several states at a time rather than focus on single states.”

For many voters, the prospect of choosing between two unpopular candidates is the worst part of this year’s presidential campaign.

Silas McLellan, a 20-year-old from Topsfield, Mass., spent several hours in the cold Tuesday in New Hampshire holding a sign for Rep. Dean Phillips (D., Minn.), who is running a long-shot campaign against Biden. He said a Biden-Trump rematch would move the country backward.

“Obviously, it’s my civic duty to vote, but I might have to sit it out because I just don’t like either candidate,” McLellan said. This year’s presidential contest is the first that McLellan is eligible to vote in.

— Catherine Lucey, Eliza Collins and John McCormick contributed to this article.

Write to Annie Linskey at annie.linskey@wsj.com, Alex Leary at alex.leary@wsj.com and Suzanne Vranica at Suzanne.Vranica@wsj.com