It was a close race for the White House and swing states were very close to call, but President Barack Obama has secured a second term in the White House.

Shortly after 11:15 p.m. Eastern time (6:15 a.m. Israel time), NBC and CNN declared Obama to be the winner of the 2012 presidential election. CNN reported that Obama had 274 electoral votes, a little more than the 270 required to win the election, and Romney had 201.

Both Obama and Republican challenger Mitt Romney grabbed early wins Tuesday in states traditionally loyal to their parties, AFP reported.

Using exit polls and early partial results, U.S. television networks projected victories for Romney in Alabama, Georgia, Indiana, Kentucky, Mississippi, Oklahoma, South Carolina, Tennessee, West Virginia, Utah and Arizona.

Obama picked up Connecticut, Delaware, Illinois, Maryland, Massachusetts, New Jersey, Rhode Island, and Vermont -- all states in which he was a favorite. He also picked up the District of Columbia as well as New Hampshire, California and Washington state.

Swing states Virginia, Florida and Ohio were too close to call, reported AFP. Networks said Virginia -- which Obama won when he was first elected in 2008 and which would be vital in almost any Romney victory strategy -- was too close to call, based on early exit polls and a small number of reported results.

Obama, however, won another swing state, Pennsylvania. The race in Florida was extremely close, with Obama having a slight lead of 50% of the votes over Romney, who had 49%. Obama was only leading by 16,000 votes. However, Obama will not need Florida to secure his win.

The final opinion polls published before voting began showed the two candidates in a dead heat nationwide, but gave Obama a slight advantage in the handful of swing states like Virginia and Ohio that will decide the race.