AS ELECTION NIGHT turned into Wednesday morning, the country found itself where many had predicted it would be: closely divided. President Bush was leading the national popular vote, and he appeared close to clinching a narrow reelection victory. But a close vote in Ohio, and the existence of thousands of uncounted provisional ballots, left open the possibility that the outcome of the 2004 election, like that of 2000, would remain uncertain for days or weeks. We hope that is not the case. The next president, whether Mr. Bush or Sen. John F. Kerry, will have enough to handle, and a hard enough time governing, without having a significant slice of the electorate questioning his legitimacy. If there is reasonable doubt about the outcome, Mr. Kerry has a right to ask that every legal ballot be counted, as his running mate, Sen. John Edwards, said last night that he would. But it was far from clear last night that the margin in Ohio and the number of uncounted provisional and absentee ballots left room for such a reasonable doubt.

On the positive side, the voting seemed to go smoothly for the most part. In some places the lines were unconscionably long, and there were machine malfunctions and other allegations of trouble. But voters seemed cheerfully oblivious to the platoons of lawyers deployed to battleground states and to the blizzard of election-related litigation that raced through state and federal courts even as voters trooped to the polls. Massive GOP challenges to supposedly questionable voters didn't materialize. Indeed, the long lines in many places, even where the outcome was scarcely in doubt, were a sign not of trouble but of robust democracy. Voters waited in the rain in Ohio and in the heat in Florida, sometimes for as long as nine hours. Turnout seemed destined to reach near-record numbers. One in 10 were first-time voters.

The flip side of massive turnout is inflamed passions, and certainly the bitter partisanship running through Washington and much of the nation will present the winner with a serious challenge -- even if there is not an ugly battle over the counting of votes. It may be too much to ask the next president to forge a new consensus about the critical issues before the country, but he needs to work to improve the current, poisonous atmosphere, and Congress and the opposition party need to work with him. In exit polls, fully one-quarter of those surveyed said that their vote was mainly against the opponent rather than for the candidate. Of those, the vast majority were Kerry supporters.

This campaign, for all its ugly moments, offered a substantive debate between two men with widely differing views on many matters. But whoever wins will have a hard time translating campaign rhetoric into policy reality, whether it is Mr. Bush's private Social Security accounts or Mr. Kerry's ambitious health care plan. Either will have to cope with a difficult war in Iraq and a constraining fiscal deficit -- though Mr. Bush could be helped by what looked to be a slightly larger GOP majority in both houses of Congress.

If he wins, Mr. Bush faces not only the challenge of a country divided on the war but a world in which many leaders, and much of the populations of other democracies, were rooting for his defeat. The president would have to show that he is willing to listen to some of these detractors even as he pursues his policies in a second term.

All presidential campaigns operate to some extent in a mythical world, but the policy debates of the 2004 campaign have taken place in more of a fantasyland than usual. Only a combination of magnanimous outreach on the new president's part and a willingness on the part of the defeated party to help him govern will enable the strong presidential leadership this country needs.