BOSTON (Reuters) - New Hampshire Governor Maggie Hassan, a Democrat, has been elected to the U.S. Senate, ousting incumbent Republican Kelly Ayotte, the New Hampshire secretary of state confirmed on Wednesday.

Hassan won by a narrow margin, recording 354,640 votes to Ayotte's 353,617, according to a final tally posted online on Wednesday.

"It will be my job in the U.S. Senate to make the best decisions for New Hampshire to work with President-elect Trump when it is in the best interest of New Hampshire and the country, and to stand up to him when it isn't," Hassan said.

(Reporting by Scott Malone; Editing by Chizu Nomiyama and Jonathan Oatis)