Barack Obama wins his second term as US president after beating Republican rival Mitt Romney. "This happened because of you," President Obama tweets.

Obama wins US election (Reuters)

Barack Obama saw off a serious challenge from Republican rival Mitt Romney to secure a second term in the White House.

The Democrat thanked his supporters on Twitter after one of the closest-run election races in history, saying: "We're all in this together."

He also sent out a picture which showed him hugging his wife Michelle Obama after the historic result became clear.

In his victory speech to adoring crowds in Chicago, the president thanked everyone who had contributed to his victory - from voters to volunteers, his vice-president Joe Biden to his daughters - and pledged: "We know in our hearts that for the United States of America the best is yet to come."

He also attempted to move on from an often bitter election battle, praising Romney's campaign and telling the nation it was getting out there that mattered.

"Whether you held an Obama sign or a Romney sign, you made your voice heard and you made a difference," he said.

"Whether I earned your vote or not, I have listened to you, I have learned from you, and you have made me a better president."

Mitt Romney called the president to concede the election at around 6am. In his concession speech, Romney said he and running mate Paul Ryan had left "everything" on the field in their months of campaigning.

Read more: US election night tops Twitter record

Please wait while this video loads. If it doesn't load after a few seconds you may need to have Adobe Flash installed.

"I have just called President Obama to congratulate him on his victory...This election is over," Mr Romney told supporters, who chanted "Mitt, Mitt, Mitt" as he left the stage.

The election was all but finished when key battleground states such as New Hampshire and Ohio were called for Obama in the early hours of the morning, taking him over the 270 electoral votes needed to secure the presidency despite the tight battle. Romney's concession sealed the deal for the president.

Hurdles ahead

While Democrats are ecstatic about the win, there are still hurdles ahead. Their party is set to retain the Senate but the Republicans are likely to keep the House. This means that the partisan roadblocks to Obama's agenda which have stymied his first four years in office are likely to remain an issue for his second term.

But for now any such concerns are on the backburner as supporters dance behind the podium at Obama's victory party in Chicago and swarm to the White House in Washington DC, cheering and waving flags.

This time round, it may not be the triumphant "Yes we can" of 2008 - but after such a close battle, it's likely many of Obama's supporters are happy that they can at least say: "We're still here."