The son of a black father from Kenya and a white mother from Kansas, the Democratic senator from Illinois sealed his historic triumph by defeating Republican Sen. John McCain in a string of wins in hard-fought battleground states — Ohio, Florida, Virginia and Iowa.
A huge crowd in Grant Park in Obama's home town of Chicago erupted in jubilation at the news of his victory. Some wept.
McCain called his former rival to concede defeat — and the end of his own 10-year quest for the White House. "The American people have spoken, and spoken clearly," McCain told disappointed supporters in Arizona.
Obama and his running mate, Sen. Joseph Biden of Delaware, will take their oaths of office as president and vice president on Jan. 20, 2009.
As the 44th president, Obama will move into the Oval Office as leader of a country that is almost certainly in recession, and fighting two long wars, one in Iraq, the other in Afghanistan.
The popular vote was close, but not the count in the Electoral College, where it mattered most.
There, Obama's audacious decision to contest McCain in states that hadn't gone Democratic in years paid rich dividends.
Obama has said his first order of presidential business will be to tackle the economy. He has also pledged to withdraw most U.S. combat troops from Iraq within 16 months.
Fellow Democrats rode his coattails to larger majorities in both houses of Congress. They defeated incumbent Republicans and won open seats by turn.
The 47-year-old Illinois senator was little known just four years ago. A widely praised speech at the Democratic National Convention, delivered when he was merely a candidate for the Senate, changed that.
Overnight he became a sought-after surrogate campaigner, and he had scarcely settled into his Senate seat when he began preparing for his run for the White House.
A survey of voters leaving polling places on Tuesday showed the economy was by far the top Election Day issue. Six in 10 voters said so, and none of the other top issues — energy, Iraq, terrorism and health care — was picked by more than one in 10.
"May God bless whoever wins tonight," President Bush told dinner guests at the White House, where his tenure runs out on Jan. 20.
The Democratic leaders of Congress celebrated in Washington.
"It is not a mandate for a party or ideology but a mandate for change," said Senate Majority leader Harry Reid of Nevada.
Said Speaker Nancy Pelosi of California: "Tonight the American people have called for a new direction. They have called for change in America."
Shortly after 11 p.m. in the East, The Associated Press count showed Obama with 338 electoral votes, well over the 270 needed for victory. McCain had 127 after winning states that comprised the normal Republican base.
The nationwide popular vote was remarkably close. Totals from 58 percent of the nation's precincts showed Obama with 51 percent and McCain with 47.9.
Interviews with voters suggested that almost six in 10 women were backing Obama nationwide, while men leaned his way by a narrow margin. Just over half of whites supported McCain, giving him a slim advantage in a group that Bush carried overwhelmingly in 2004.
The results of the AP survey were based on a preliminary partial sample of nearly 10,000 voters in Election Day polls and in telephone interviews over the past week for early voters.
Democrats also acclaimed Senate successes by former Gov. Mark Warner in Virginia, Rep. Tom Udall in New Mexico and Rep. Mark Udall in Colorado. All won seats left open by Republican retirements.
In New Hampshire, former Gov. Jeanne Shaheen defeated Republican Sen. John Sununu in a rematch of their 2002 race, and Sen. Elizabeth Dole fell to Democrat Kay Hagan in North Carolina.
Democrats also looked for gains in the House. They defeated Republican incumbents Rep. Tom Feeney and Ric Keller in Florida, 22-year veteran Chris Shays in Connecticut and Rep. Robin Hayes in North Carolina.
At least two Democrats lost their seats. Rep. Kevin Mahoney fell after admitting to two extramarital affairs while serving his first term in Florida. In Louisiana, Democratic Rep. Don Cazayoux lost the seat he had won in a special election six months ago.
The resurgent Democrats also elected a governor in one of the nation's traditional bellwether states when Missouri Attorney General Jay Nixon won his race.
The White House was the main prize of the night on which 35 Senate seats and all 435 House seats were at stake. A dozen states elected governors, and ballots across the country were dotted with issues ranging from taxes to gay rights.
An estimated 187 million voters were registered, and in an indication of interest in the battle for the White House, 40 million or so had already voted as Election Day dawned.
Obama sought election as one of the youngest presidents, and one of the least experienced in national political affairs.
That wasn't what set the Illinois senator apart, though — neither from his rivals nor from the other men who had served as president since the nation's founding more than two centuries ago. A black man, he confronted a previously unbreakable barrier as he campaigned on twin themes of change and hope in uncertain times.
McCain, a prisoner of war during Vietnam, a generation older than his rival at 72, was making his second try for the White House, following his defeat in the battle for the GOP nomination in 2000.
A conservative, he stressed his maverick's streak. And although a Republican, he did what he could to separate himself from an unpopular president.
For the most part, the two presidential candidates and their running mates, Biden and Republican Gov. Sarah Palin of Alaska, spent weeks campaigning in states that went for Bush four years ago.
McCain and Obama each won contested nominations — the Democrat outdistancing former first lady Hillary Rodham Clinton — and promptly set out to claim the mantle of change.
Obama won Colorado, Nevada, California, Hawaii, Oregon, Washington, Florida, Virginia, New Mexico, Iowa, Ohio, Wisconsin, Michigan, New York, Rhode Island, Minnesota, Pennsylvania, New Hampshire, Vermont, Connecticut, Delaware, Illinois, Maine, Massachusetts, Maryland and New Jersey, as well as the District of Columbia.
McCain had Nebraska, Idaho, Mississippi, Texas, West Virginia, Utah, Arkansas, Kansas, Kentucky, Tennessee, Oklahoma, Wyoming, Alabama, South Carolina, Louisiana, South Dakota and North Dakota.