In the gubernatorial race, former Democratic state Sen. Maggie Hassan defeated Republican Ovide Lamontagne to become the second woman elected New Hampshire's governor.
With nearly all votes counted, Obama defeated Romney 52 percent to 47 percent, a 5-point lead he maintained nearly throughout the counting.
In the governor's race, Hassan defeated Lamontagne 56 percent to 42 percent, with almost all votes counted. Libertarian Party nominee John Babiarz of Grafton collected 3 percent.
Hassan defeated Lamontagne in his home ward in Manchester, 1,946 to 1,548.
New Hampshire went for Obama in 2008 and Democratic nominee Sen. John Kerry in 2004. But the state has long been a battleground, and its voters are widely viewed as independent.
Romney won the state's first-in-the-nation primary in January, and Romney has a home in the state on Lake Winnipesaukee. He was also governor of neighboring Massachusetts from 2003 to 2007.
Hassan, 54, a state senator from 2004 to 2010, said education and jobs would be her focus if elected governor. She was endorsed by former U.S. President Bill Clinton and the National Education Association's state chapter.
She has pledged not to support a state income or sales tax as governor.
Lamontagne, 55, is a lawyer and conservative stalwart who unsuccessfully ran for governor in 1996 and for the Republican nomination for the U.S. Senate in 2010.