A tractor-trailer hauling 9,500 gallons of fuel rolled over at a Gorham rotary Wednesday afternoon, leaking nearly its entire load into nearby wetlands and threatening to contaminate a Stroudwater River tributary.

The crash took place just before 2 p.m. at the intersection of routes 114 and 112 in Gorham. The road remained closed through the evening commute and southbound lanes were expected to stay closed through Thursday morning’s commute.

The driver, Fred Bird, lost control of the truck, causing it to tip over. Bird was not injured, and a passenger – a truck-driver trainee – also escaped injury.

The truck, which is owned by the J.P. Noonan company of Gorham, landed in a ditch, rupturing one of its four storage tanks, said Scarborough Fire Chief Michael Thurlow, who was handling media inquiries about the incident.

Initially, authorities believed fuel spilled from only one of the truck’s storage tanks, but on Wednesday night, Thurlow said an investigation showed the truck’s internal valve system failed, causing all but 600 of the 9,500 gallons of fuel to spill onto the ground and into nearby wetlands.

Emergency crews were able to prevent the spill from entering the Stroudwater River, which is located about a half-mile away from the accident scene, Thurlow said.

Thurlow said it could take days for crews from the Maine Department of Environmental Protection and its subcontractor, CleanHarbors, to clean up the spill.

The truck was hauling 6,500 gallons of diesel fuel and 3,000 gallons of kerosene. Jessamine Logan, DEP spokeswoman, said Wednesday night that crews had recovered about 6,500 gallons.

The cause of the crash remains under investigation, but Lt. Chris Sanborn of the Gorham Police Department said Bird told police he lost control of the truck when he tried to avoid hitting a dark-colored sedan that pulled in front of him.

Sanborn said police will try to determine how fast the truck was traveling and whether it had any mechanical problems. State police, who are assisting Gorham police in their investigation, will inspect the truck Thursday.

Police are also checking the truck’s log books to make sure Bird complied with keeping his log hours up to date.

Sanborn did not know how long Bird had been driving for J.P. Noonan, but said, “The company is very reputable. They have never had a crash like this.”

Fire departments from Gorham, Scarborough and South Portland responded to the crash.

South Portland sent a truck carrying special flame-suppressing foam, and tankers from Hollis, Raymond, Gray and other communities responded as a precaution because the area is not served by hydrants. There was no fire.