WINDHAM, N.H. — For much of this presidential primary season, New Hampshire has been perceived as being in Mitt Romney’s back pocket. He has a house in Wolfeboro, N.H., and was governor of neighboring Massachusetts, where the news media made him a constant presence in New Hampshire living rooms.

But as in other early voting states, Newt Gingrich has unexpectedly surged in the polls here in recent weeks. While Mr. Romney still holds the lead, Mr. Gingrich tops the polls in Iowa, South Carolina and Florida, gaining enough steam that while here on Monday, he repeatedly referred to himself as the front-runner.

The stakes were evident Monday as the two candidates campaigned here and engaged in their most intense skirmishes to date. Mr. Romney demanded that Mr. Gingrich return the $1.8 million in consulting fees he had received from Freddie Mac; Mr. Gingrich, a former House speaker, cast aside a vow not to attack his opponents and responded that Mr. Romney should “give back all the money he earned from bankrupting companies and laying off employees over his years at Bain.”

Until now, the two had circled each other warily and largely refrained from direct attacks, often using surrogates instead. But with both men on the ground here, they took to swatting at each other directly, highlighting just how important the New Hampshire primary may be in framing the fight for the Republican nomination.