US President George W Bush will not leave office until 20 January 2009, but the battle to succeed him is over.
The US president has been a Bush or a Clinton since 1988
John McCain conceded the race to Barack Obama after it became clear he had taken more than the 270 electoral college votes needed to win.
Who has been elected?
The 44th president of the United States. At the same time, elections have been held for all seats in the House of Representatives and one-third of the seats in the Senate. Eleven state Governors have also been elected.
The Democratic Party's candidate was Barack Obama - the first black person to be nominated by either main party, with Delaware Senator Joe Biden as his running mate.
The Republican Party's candidate was John McCain, a 72-year-old Vietnam veteran who, had he succeeded, would have been the oldest president sworn in for a first term. His choice for vice-presidential candidate was 44-year-old Alaska Governor Sarah Palin.
The election was also notable for who was not running - it was the first since 1928 in which neither an incumbent president nor vice-president sought his party's nomination. (Though in 1952 the incumbent president dropped out early in the race.) George W Bush could not stand again because the US Constitution limits a president to two terms in office.
Which party had the best chance?
A majority of voters had a low opinion of the Bush presidency. This, and the poor state of the economy, gave the Democrats an advantage.
The number of people who said they identified with the Democratic Party also significantly exceeded the number who said they identified with the Republican Party. According to a Pew Research Center poll, the gap was "the highest recorded during the past two decades".
The Democratic-controlled Congress had scored even lower approval ratings than Mr Bush but, nonetheless, the Democrats extended their majorities in both the House of Representatives and the Senate.
What were the main issues?
The state of the economy was the biggest problem agitating American voters. Iraq was another major issue, and one on which the two main candidates were divided - Mr Obama pledged to withdraw US troops rapidly, while Mr McCain foresaw a gradual withdrawal as the situation in the country stabilised.
Concerned by rising fuel prices, both candidates argued for a reduction in US dependence on imported oil, but there were differences in emphasis. Mr McCain was keen on drilling new oil wells off the US coast, while Mr Obama favoured higher fuel efficiency standards for cars.
Healthcare reform remained an important issue for many voters. Liberal voters particularly wanted to see more people covered by insurance, while conservative voters were keen to see costs controlled and insurance premiums brought down.
Social issues such as abortion, stem cell research and gay marriage seemed to be slightly less important to voters than they were at the time of the last election in 2004.
Which were the key battleground states?
The pattern in recent years had been that most of the states on the east and west coasts voted Democrat and most of the others voted Republican.
However, there were a number of states that could have swung either way, polls suggested. These included Florida, Ohio and Pennsylvania (each with 20 or more electoral college votes), and also Colorado, Indiana, Missouri, Nevada, New Mexico, North Carolina, North Dakota, Virginia and West Virginia.
Virginia and North Dakota had not voted for a Democratic presidential candidate since 1964.
Does the candidate who gets the most votes win the presidency?
Not necessarily. Voters do not, technically, participate in a direct election of the president. They choose "electors" pledged to support a particular candidate - these are the people who actually elect the president. (There are 538 of them, and big states have more of them than small states.)
In every state except Maine and Nebraska, the winner of the popular vote gets all the electoral college votes in that state, even if his or her majority is wafer thin. So it can happen that a candidate ends up with more electoral college votes than the rival candidate, and yet a smaller share, nationally, of the popular vote.
Were there any third-party candidates?
Independent candidate Ralph Nader ran this year, as he did in 2000 and 2004. Accused by some Democrats of splitting the left-of-centre vote in 2000, and allowing George Bush to win, he was not a major factor in the 2008 race.
There was also a third-party candidate on the right, Bob Barr, who ran for the Libertarian Party. Green Party and Constitution Party candidates also ran.