Barack Obama was elected the nation's first black president Tuesday night in a historic triumph that overcame racial barriers as old as America itself.

The 47-year-old Democratic senator from Illinois sealed his victory by defeating Republican Sen. John McCain in a string of wins in hard-fought battleground states - Ohio, Florida, Virginia and Iowa.

A huge crowd thronged Grant Park in Chicago to cheer Obama's improbable triumph and await his first public speech as president-elect.

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 counted.

There, Obama's audacious decision to contest McCain in states that hadn't gone Democratic in years paid rich dividends.

Fellow Democrats rode his coattails to gains in both houses of Congress, toppling Republican incumbents and winning open seats alike.

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.