MATTAWAMKEAG, Maine — Emergency workers will be handling crude oil a few yards from the Penobscot River overnight Thursday after 13 full 31,000-gallon train tanker cars derailed and tipped over, spilling just 3 gallons, officials said.

The Pan Am Railways tanker cars, which were among 15 that derailed on the 96-car train, went off the tracks near Route 2 and the Winn town line about 5 a.m. Thursday. No injuries were reported. Thirteen of the 15 cars tipped over but none ruptured, said Pan Am Railways Executive Vice President Cynthia Scarano.

Scarano described the oil spill as that which typically accumulates around the two hatches atop the tank when tanks are filled or emptied. About a gallon of oil came from three overturned tankers, Mattawamkeag Fire Chief Robert Powers said.

“Three gallons — that’s amazing [when you] have the cars laying on their sides, a couple of them in trees,” Powers said. “They’ve built the rail cars to sustain derailment. We are very thankful that that’s where we are at right now.”

Maine Department of Environmental Protection crews and a private contractor will be working with Pan Am to transfer oil from the 13 tankers to 20 smaller tankers. The work likely will continue for two or three days, said department spokeswoman Samantha Warren, who said the spill could have been “disastrous.”

Workers emptied the first car at about 9:15 p.m. The offloading went well, but the work “will be delicate,” she said.

“There are still hundreds of thousands of gallons of crude oil in derailed cars within sight of the Penobscot River,” Warren added, joining a chorus of voices from the state Legislature and environmentalist community that called the accident’s lack of environmental damage a miracle.

Scarano said a severe leak into the river was never very likely. The train was on a stretch of track from Waterville to Canada that is rated Class 1, which means suitable for traffic moving no faster than 10 mph.

The Federal Railroad Administration investigation of the accident is continuing, but it appears that the train was moving no faster than the speed limit. Firefighters said train workers told them it was traveling 8 mph when the derailment occurred.

A slow speed would be logical, Scarano said, given that the train was approaching a switch in town. Its cargo was to be transferred to New Brunswick Southern Railway for eventual arrival at a refinery in Saint John, New Brunswick. She said the train had three engines pulling it.

The tankers were filled in the Baaken oil fields in North Dakota, and were heading to Canada.

The accident occurred just west of 10 Main St. in what is almost the backyard of Dave Markie and his family, but didn’t wake them, Markie said. He and several other residents said that trains go through the area often and minor train derailments, in which cars leave the tracks but don’t tip over, are common occurrences.

“All I heard was the [train] engines running,” Markie said.

Emergency workers gathered along Route 2 and in Markie’s long driveway, just south of Markie’s Garage, for most of the day. A freight engine pulling three freight cars was stopped along the track about a half-mile south of the scene. A long line of tanker cars, possibly to be used for oil transfers, replaced the engine just before dusk.

Maine Department of Transportation crews came to help Federal Railroad Administration investigators determine the accident’s cause, DOT spokesman Ted Talbot said.

“We will follow their lead,” Talbot said. “We are trying to, if we can, identify what went wrong based on what we are seeing now. When the tankers are turned upright and able to move, we will take a second look to see what went wrong.”

An FRA investigator at the scene declined to comment.

This is the second time in less than a year that a Pam Am derailment threatened the Penobscot River, Warren said. Four cars derailed, with two going into the river, near the Bucksport-Orrington town line last May. The cars carried nonhazardous clay slurry used in papermaking.

Trains pulling tankers north to Canada have become a much more common sight along this rail line in the past year as oil drilling operations in the Northwest increase shipments into Canada and overseas, several residents said.

Of the more than 220 million gallons of oil that crossed Maine in 2012, Pan Am hauled about 105 million gallons, Scarano said. Pan Am has 900 workers in the U.S. Northeast and expects to hire 35 to 40 new train/engine crews this year, she said.

Mattawamkeag resident Timothy Coombs said he wasn’t surprised at the accident. The track’s recent heavy use, often punishing weather conditions and the track’s degraded condition along some stretches made the accident inevitable, residents said.

“It is just something that happens all the time,” Coombs said. “They usually don’t lay on their sides like they did today, but it happens down here four or five times a summer. They usually just derail.”

Scarano said the track was in excellent condition for a Class 1 line, though Class 1 is the slowest-speed track. A Class 5 track can handle 79 mph traffic. The Mattawamkeag stretch of tracks is rated Class 1 more for its use than condition, Scarano said.

Federal Railroad Administration workers inspected the track last fall and found no significant defects, Scarano said. Pan Am, which typically inspects its tracks at least once a week, inspects the Mattawamkeag-area tracks four times a week, she said.

Pan Am does regular maintenance and upgrades on its rail lines and “did a big project from Mattawamkeag south replacing ties” and other repairs recently, Scarano said.

Once the tipped tanks are emptied, Pan Am will use large cranes to right the tanker cars if possible, Scarano said.

Maine DEP will observe the oil transfer and other work overnight and Friday. A heated tent has been set up for emergency workers, Warren said. DEP handles about 3,000 oil and hazardous chemical spills annually.

“This still remains a very active emergency response,” Warren said. “We still have a ways to go, but we are optimistic that the recovery effort will proceed as things have thus far, with no apparent environmental damage.”

“I think it is incredibly fortunate,” Warren said, “that we measured the amount of discharge in drops instead of hundreds of thousands of gallons.”