Media playback is unsupported on your device Media caption Barack Obama: "I have never been more hopeful"

President Barack Obama has been re-elected to a second term, defeating Republican challenger Mitt Romney.

America's first black president secured more than the 270 votes in the electoral college needed to win.

In his victory speech before supporters in Chicago, Mr Obama said he would talk to Mr Romney about "where we can work together to move this country forward".

Mr Obama prevailed despite lingering dissatisfaction with the economy and a hard-fought challenge by Mr Romney.

His Democrats also retained their majority in the Senate, which they have held since 2007.

[an error occurred while processing this directive]

The Republicans kept control of the House of Representatives, which analysts say will likely result in more of the gridlock that characterised Mr Obama's first term, with the House and the president at loggerheads on most legislation.

In his address, the president challenged his opponents, asking them to work with him.

With only Florida's 29 electoral votes still undecided, Mr Obama won 303 electoral votes to Mr Romney's 206.

The popular vote, which is symbolically and politically important but not decisive in the race, remains very close.

Both candidates said this was a choice of two visions - America has chosen

'One nation' speech

Mr Obama congratulated Mr Romney and Republican vice-presidential candidate Paul Ryan on their hard-fought campaign.

"We have picked ourselves up, we have fought our way back and we know in our hearts that for the United States of America the best is yet to come," he said.

Mr Obama said he was returning to the White House "more determined, and more inspired than ever about the work there is to do, and the future that lies ahead".

He pledged to work with Republican leaders in Congress to reduce the government's budget deficit, fix the tax code and reform the immigration system.

"We are an American family and we rise and fall together as one nation," he said.

In Boston, where his campaign was based, Mr Romney congratulated the president and said he and Mr Ryan had "left everything on the field" and had given their all in the campaign.

US media reaction Thomas L Friedman of the New York Times writes: "No one can know for sure what complex emotional chemistry tipped this election Obama's way… it came down to a majority of Americans believing that whatever his faults, Obama was trying his hardest to fix what ails the country." Dan Balz of the Washington Post says: "Tuesday's election produced an uncertain mandate, although Obama will attempt to claim one. Obama offered a plan, but not one that deals directly with some of the problems he will have to confront immediately." A Wall Street Journal opinion piece read: "[Obama] said little during the campaign about his first term and even less about his plans for a second. Instead his strategy was to portray Mitt Romney as a plutocrat… it worked with brutal efficiency - the definition of winning ugly." Doyle McManus of the Los Angeles Times writes: "If we're lucky, we will find that we elected a different Obama from the one who won four years ago - not just a grayer Obama but a wiser one too."

Referring to the struggling economy, Mr Romney said now was not the time for "partisan bickering and political posturing", and that Republicans and Democrats must "put people before politics".

"I so wish that I had been able to fulfil your hopes to lead the country in a different direction but the nation chose another leader and so I join with you to earnestly pray for [Mr Obama] and for this great nation," he said.

Under the US constitution, each state is given a number of electoral votes in rough proportion to its population. The candidate who wins 270 electoral votes - by prevailing in the mostly winner-takes-all state contests - becomes president.

On Tuesday, the president held the White House by assembling solid Democratic states and a number of important swing states such as Colorado, Iowa, Pennsylvania, Michigan, Minnesota, Virginia and Wisconsin. His narrow victory in Ohio, a critical Mid-Western swing state, sealed the victory.

In other key ballots:

Referendums in Maine, Maryland and Washington state approved same-sex marriage, while a measure in Minnesota to block gay unions failed

Colorado and Washington state voted to legalise recreational use of marijuana

California voters rejected a proposal to abolish the death penalty

In a referendum, Puerto Ricans voted in favour of becoming the 51st US state, if Congress approves the move.

Billions spent

Mr Romney won North Carolina and Indiana, both of which Mr Obama won in 2008, as well as the solid Republican states.

But he was unable to win in Ohio or other states needed to breach the 270 threshold.

Also on Tuesday's ballot were 11 state governorships, a third of the seats in the 100-member US Senate and all 435 seats in the House of Representatives.

Mr Obama's victory came despite lingering high unemployment - 7.9% on election day - and tepid economic growth.

But voters gave him credit for his 2009 rescue of the US car industry among other policy accomplishments, and rewarded him for ordering the commando mission that killed Osama Bin Laden in Pakistan last year.

He and Mr Romney, as well as their respective allies, have spent more than $2bn (£1.25bn) - largely on adverts in swing states.