Thousands of gallons of oil leaked onto frozen ground after a train carrying crude from Canada derailed Wednesday in western Minnesota.

The 94-car Canadian Pacific train was headed south near Parkers Prairie when it lost air pressure and went into an emergency braking mode, the Otter Tail County sheriff's office said. Fourteen tankers derailed. Three either leaked or spilled oil. No one was hurt, and a spokesman for the state's pollution control agency said crews were able to control the spill.

An estimated 20,000 to 30,000 gallons leaked onto the ground, Minnesota Pollution Control Agency spokesman Dan Olson said. The spill was contained in a field and ditch in a rural area, and the cold weather helped keep the spill contained and prevented oil from moving down the ditch or into the ground, Olson said.

One heavily damaged car spilled much of its 26,000-gallon load, Olson said. He said the oil was "just oozing out" in the cold.

Because the ground is frozen, there's no threat to water, Olson said. Initial recovery efforts likely will take a day or two, and excavations then will be done to determine if any oil leaked into the soil, he said.

The railroad was cleaning up the spill, Canadian Pacific spokesman Ed Greenberg said.

While the spill appeared to be under control from an ecological standpoint, it could play a role in the politics surrounding the Keystone XL pipeline, which would transport oil from tar sands in Canada to refineries in Texas. Environmentalists have criticized the proposal, saying that a pipeline could be prone to spills and would ensure that the carbon-laden tar sands are fully developed. A recent analysis from the State Department seemed to knock down one of their arguments, by saying that when it comes to global warming, shipping the oil by pipeline would release less pollution than using rail.

Greenberg said he did not know if the oil that spilled was tar sands oil. The train, carrying a mix of cargo, originated in western Canada and was bound for Chicago, he said.