After the longest and costliest campaign on record, President Bush and challenger John F. Kerry remained deadlocked nationally and in key battleground states yesterday, with both sides expressing confidence that late trends and their Election Day get-out-the-vote operations will deliver a victory when the polls close tonight.

As the two blitzed through their final rallies in Florida, Ohio, Iowa, Wisconsin and other states late into the night, a flurry of national polls completed over the weekend showed them in a statistical tie. Neither candidate has been able to establish clear momentum.

Several of the national polls were tied. In the others, the president led more often than the senator from Massachusetts, but by margins so minuscule -- a single point in some cases -- as to be meaningless in attempting to predict the outcome. But Bush generally remained just below 50 percent nationally, a potentially risky place for an incumbent.

Even before the opening of polls across the country today, a record number of Americans had voted, either by absentee ballot or under state laws that allow early voting. In the battleground states, more than 5 million Americans have voted, according to a Democratic Party analysis. The long lines in Florida that have kept some voters waiting for two hours or more symbolize the engaged electorate.

Both sides are braced for problems at the polls, with teams of lawyers in many states poised for battle over voting procedures. Today's voting promises to be the most heavily monitored and potentially the most disputed in modern times. The prospect of further legal warfare and a drawn-out process of counting the vote could aggravate the raw feelings of partisans in both parties.

The first presidential election since the terrorist attacks of Sept. 11, 2001, and subsequent wars in Iraq and Afghanistan find the country as deeply divided as it was in the aftermath of the disputed 2000 election that put Bush in the White House. Bush lost the popular vote but won the necessary electoral voters after the Supreme Court sided with him in a dispute over a recount in Florida. This year's campaign was marked by relentless attacks from both sides.

For much of the year, Bush has run against a headwind of bad news, particularly out of Iraq, which has negated some of the usual advantages of incumbency. In the past week, headlines told of kidnappings and casualties in that country. A report about missing munitions provoked days of debate about Bush's management of the war.

In their last assessments of the race, both campaigns said they see several combinations of states that would yield the 270 electoral votes needed for victory. Two of the biggest battlegrounds, Florida and Ohio -- both in Bush's column in 2000 -- were too close to call yesterday.

But Pennsylvania, once seen as leaning to Kerry, may have tightened up over the weekend. A victory by Bush in Pennsylvania, which Democrat Al Gore won four years ago, would create a huge hurdle to Kerry's hopes of winning the White House. Democratic strategists said they expect to win the state, albeit more narrowly than they once believed.

In Florida, each campaign said it was encouraged by the early voting. But the state's size and the diversity of its electorate, coupled with the emotions remaining from the 2000 recount, make it perhaps the most difficult battleground state to read.

Ohio, which no Republican has lost and still won the White House, appeared to be a tossup. The University of Cincinnati's Ohio Poll yesterday put Bush at 50.1 percent and Kerry at 49.2 percent, and a Columbus Dispatch poll on Sunday called the race 50-50, the closest in the poll's history.

Three upper Midwest states also remain close. Minnesota continues to tilt toward Kerry, with Bush still hoping for an upset. In Wisconsin, both sides said the outcome is likely to be determined on the ground today. Bush strategists believe Iowa is the most likely state to take from the Democrats, but one adviser to Kerry said yesterday the state has begun to move his way.

Bush's campaign also sees New Mexico as a potential pickup, and Kerry's team believes the Democrat will take back New Hampshire. Democrats see Nevada as still in play, but the Bush camp believes it will remain in the red-state column. Bush is still fighting to win Michigan but appears to have an uphill fight.

Karl Rove, Bush's chief political adviser, predicted victory, saying the president will win Florida and Ohio and "two, three or four states" won by Gore in 2000. Matthew Dowd, the campaign's chief strategist, predicted that Bush will win the popular vote by three percentage points.

Kerry campaign spokesman Joe Lockhart countered with an optimistic appraisal of his own. "We think nationally this race is a dead heat, but in the battleground states we have a significant advantage," he said. "We think we have an advantage in both Ohio and Florida, and New Hampshire and Nevada are well within range."

Donna Brazile, manager of Gore's 2000 campaign, said: "I have not seen this kind of energy and excitement in the African American community since Jesse Jackson was running for the nomination back in 1984. People are pumped."

Brazile said that when she began making pro-Kerry calls to black radio stations at 7 a.m. yesterday, she found that many had already heard the same message from former president Bill Clinton.

Strategists in the two campaigns said four factors are likely to determine the outcome.

The first is how many people vote. Four years ago, about 106 million Americans cast ballots, and everything points to an increase this year. Some analysts predict that participation rates could equal or top those of 1992, which would mean close to 120 million voters. A huge increase is likely to favor Kerry.

The second question is which party is better at turning out its vote. Republicans hope to narrow or eliminate what has been a historical disadvantage on Election Day. In the past several presidential elections, Democrats made up about 39 percent of the electorate to the Republicans' 35 percent. The closer Republicans come to parity, the better Bush's chances of winning. Polls consistently show Republican support for Bush is more solid than Democratic support for Kerry.

A third key variable is how many first-time voters and young voters turn out. Four years ago, first-time voters accounted for 9 percent of the electorate, but with significant increases in registration in many battleground states, that number could rise. This election, unlike the 2000 contest, also has generated far more interest among voters under 30, and a sharp jump in their participation is possible. If it occurs, Kerry is likely to benefit; a Washington Post tracking poll showed him leading Bush, 60 percent to 37 percent, among likely voters under 30.

Finally, the two campaigns disagree about the electorates in the battleground states. Bush campaign strategists say the battleground states will track the national returns, but Kerry strategists say the senator has an advantage in the battlegrounds because they have seen the candidates constantly and have absorbed advertising nonstop since March.

Whoever wins this election will face a significant challenge unifying the country. An NBC News-Wall Street Journal poll asked people whether they agreed or disagreed with the statement, "No matter who wins the election, America will have a good president." Just 30 percent said they agreed and 65 percent said they disagreed.

Under the watchful eye of poll observers, at left, voters line up at Leon County Courthouse in Tallahassee, Fla., to cast their presidential ballots early. Some reported waits of two to three hours to vote.