Crews doused highly flammable styrene after train derailment in southern Alta.

Residents were able to return to their homes Friday night after a train derailment and chemical spill near Irvine, Alta. The county confirmed Saturday that the leaked material was the highly flammable substance styrene.

About 80 emergency personnel fought fire, crews needed heavy equipment to untangle 'train pretzel'

A train derailment is shown near the hamlet of Irvine, Alta., on Friday. (HO-Trehia Steveson/The Canadian Press)

Residents in Cypress County in southeastern Alberta are back in their homes after a train derailment led to a chemical spill near the community.

The county confirmed Saturday that the leaked material was the highly flammable substance styrene.

An Alberta Emergency Alert told residents within a seven-kilometre radius to evacuate the area immediately on Friday afternoon. 

The train derailed on the west side of Irvine — a community of about 300 people, some 35 kilometres southeast from Medicine Hat — along the north side of Highway 1 in Cypress County, officials said.

About 80 first responders were at the scene in addition to Canadian Pacific (CP) workers and contractors.  Kim Dalton, director of emergency management for Cypress County, said it was a massive response.

"There was approximately 20 cars that came derailed," Dalton said. "They were intertwined with some of the railway track. Crews brought [out] an enormous amount of heavy equipment and they untangled the train pretzel."

According to Dalton, styrene can react with water which made a fire at the scene even more challenging. 

A train derailment just east of Medicine Hat, Alta., led to an evacuation after a chemical spill. Residents have since returned home. (Trehia May Stevenson/Facebook)

Fire crews used foam to douse the site and to extinguish the flames. Dalton said there is no longer a fire risk. 

"The chemical has all been contained," Dalton said. "Crews worked through the night and we're using earth material to help soak up the matter and alleviate any environmental contamination."

Residents were allowed back into the area late Friday night.

Alberta Environment was on scene monitoring the cleanup. Dalton said they were satisfied with CP's response to the situation. 

Those living in the area can expect a steady stream of train traffic to roll through over the weekend after the line was shut down Friday. 

Cypress County declared a local state of emergency Friday evening after a train derailment in the area. Firefighters contained the flammable substance styrene. (Jennifer Radisic/Facebook)

 Dalton said the closure of the track has led to a major backlog between the communities of Dunbar and Irvine.

"Every hour that train line is closed is a serious blow to the logistics of [Canadian Pacific] for western Canada," Dalton said. "So, they want to ensure that that line gets open as soon as possible. We will be anticipating a heavy flow of train traffic through the region over the next 24 to 48 hours."

Investigators from the Transportation Safety Board remain at the scene. They are continuing to investigate the cause of the derailment.