FILE - In this Dec. 8, 2011 file photo, the Amtrak Downeaster passenger train travels through Portland, Maine. Banners were being installed and track work continued Wednesday, Sept. 12, 2012, as the rail line is prepared to extend its route from Boston and Portland onward to Brunswick in November.  (AP Photo/Robert F. Bukaty)
FILE - In this Dec. 8, 2011 file photo, the Amtrak Downeaster passenger train travels through Portland, Maine. Banners were being installed and track work continued Wednesday, Sept. 12, 2012, as the rail line is prepared to extend its route from Boston and Portland onward to Brunswick in November. (AP Photo/Robert F. Bukaty) Credit: Robert F. Bukaty

The New Hampshire House approved the use of federal funds to study commuter rail within the state on Thursday, overturning a committee decision in a surprise move.

In a 166-160 vote, representatives gave the green light to a last-minute amendment to the stateโ€™s 10-year transportation plan, allowing $4 million in federal money to go toward designing a rail corridor that could connect Concord, Manchester and Nashua to Massachusetts.

The revised bill overrides an attempt by a House committee to divert the money into a study of bus service expansion from Concord to Nashua, which connects to Boston.

Commuter rail has long been politically divisive with Democrats holding it up as a key to attracting younger residents and Republicans deriding it as a waste of public money thatโ€™s unlikely to attract demand.

As passed on Thursday, House Bill 2018 โ€” the 10-year transportation improvement plan โ€” would now use the federal funds toward both the rail and bus services studies.

Democrats were elated.

โ€œCommuter rail is a top priority of our stateโ€™s business community, and is strongly supported by Granite Staters,โ€ said House Democratic Leader Steve Shurtleff in a statement.

The move came unexpectedly, adding to what has been a volatile journey for the rail study in the past year.

A spokesman for Gov. Chris Sununu was not available to comment on the governorโ€™s position on the amended plan.

But House Republicans made their objections heard.

โ€œWeโ€™ve already studied it over and over,โ€ said Rep. Al Baldasaro, R-Londonderry.