Freight trains are now rolling through New England carrying the first-ever shipping containers loaded on the Portland waterfront. The new train service is the product of years of planning and millions of dollars in public and private investment, with the goal of connecting this once-thriving port by rail with freight customers throughout North America.

State officials see the rail link as key to reviving the port, which was among the largest on the East Coast a century ago but had fallen in past decades to a near-dormant state, losing business to larger ports.

Stuck at the end of the nation’s supply line, Maine businesses have struggled with higher transportation costs, which make manufacturing less competitive and increase prices for consumers.

The administration of Gov. Paul LePage has been trying to change those dynamics, first in 2013 by luring Eimskip, an Icelandic shipping company, to carry containerized cargo between Portland and Europe, and then by expanding the Portland container terminal. Officials used $29 million in state and federal money to modernize the terminal and add about 1,500 feet of track to connect with the end of an existing rail line that previously had only carried bulk cargo, such as rolls of paper, to and from the port.

The opening of the rail link is a historic moment for the port, said Jack Humeniuk, vice president of the Portland Longshoremen’s Benevolent Association, whose members loaded the containers onto flat rail cars. “We’re not looking at Maine as being at the end of the transportation trail, but as the front door to a different part of the world.”

The new facility allows containers to be moved between ships and trains, and also between trucks and trains.

Pan Am Railways began the service Friday, hauling Poland Spring bottled water packed in blue Eimskip containers as part of the first phase of a pilot project. Three days a week – Friday, Saturday and Sunday – a train carrying 15 containers of bottled water will travel to Ayer, Massachusetts. There, the containers will be put on trucks and delivered to nearby wholesale suppliers.

Until now, Maine companies that lack rail access had to truck containers to terminals in Ayer and Worcester, Massachusetts. It’s generally cheaper to move heavier cargo by train than by truck, because more can be moved at one time, with lower fuel costs and fewer workers.

Because Pan Am trains will carry containers delivered by both truck and ship, it will have enough volume to support regular service to Portland, Humeniuk said.

Chop Hardenbergh, editor of Atlantic Northeast Rails & Ports, a trade publication, said he is skeptical that the new terminal will be successful. He said he has seen others in Maine fail because there hasn’t been enough demand to make the operations economical.

“The big unknown is what Eimskip can bring to this,” he said. “Can Eimskip add enough volume so Pan Am will say it’s worthwhile to run a train?”