A massive fire that broke out at a railyard in Port Coquitlam, B.C. Monday night was extinguished after about eight hours of battling the blaze.

The three-alarm fire broke out after a tanker truck and a train collided at the Canadian Pacific Railyard at around 6:35 p.m.

The fire, which quickly grew in the area of Lougheed Highway and Shaughnessy Street, triggered dozens of evacuations. Crews worried there could be an explosion at any time, as the truck was loaded with ethanol and the train was carrying flammable material.

Officials said the driver was able to escape unharmed as the truck was engulfed in flames. Several explosions were heard by those in the area and thick smoke could be seen from a distance.

"I was horrified when I heard about it, when I saw the images of the fire. This is a highly densely populated community and it was a shock to see," B.C.'s public safety minister told CTV News Tuesday morning.

Min. Mike Farnworth said he was notified by Canadian Pacific after the crash occurred.

Mayor Greg Moore said he was also in communication with CP through the night, as well as the city's emergency preparedness group.

"It's very concerning and that's why we do tabletop exercises with CP and our fire department. A few years ago we actually did an exercise about a truck or train blowing up like this and how would we react as a community," he said.

Nearby homes and businesses were emptied, with residents given only about 10 minutes of notice. Fortunately no injuries have been reported.

Meanwhile, an army of firefighters swarmed the scene as the flames grew.

Fire Chief Nick Delmonico said his department was using "pretty much everything we have," but had to wait until nearby train cars containing dangerous materials were moved out of the way before it could begin fighting the fire.

Abbotsford Mayor Henry Braun tweeted saying his city was sending a foam truck and trailer with a police escort to assist in the firefighting efforts.

Firefighters used the foam retardant to get the blaze under control, but it flared up again Tuesday morning when crews tried to separate the train and the tanker. When the train was moved, a pile of burning metal was visible on the tracks.

Farnworth said he couldn't give first responders enough credit for their handling of the incident.

"I think the first responders – the Port Coquitlam Fire Department, police – responded quickly, admirably. I think they did an amazing job," he said.

The cause of the crash is under investigation, Canadian Pacific said. Mounties are working with CP's police service to determine what happened.

Coquitlam RCMP Cpl. Michael McLaughlin said all parties are cooperating with police. A cleanup of the area is complete and all roads closed as a result of the fire have reopened.

Moore said it's still early in the investigation, but that it appeared that the truck was on the tracks when the train hit it. Everyone was able to get out safely because they saw the train coming, and trains are only permitted to travel at a maximum speed of about 15 km/h in the yards, so it hadn't been moving too quickly at the time.

"The bigger concern last night was what was around that train. What was on the train. So if it was an isolated incident like it was, then we're able to deal with it and we saw it turned out fairly OK, but my bigger concern is what else is around in that yard," he said.

Moore said many questions remain, and that answers are needed to ensure it doesn't happen again.

"We talk about natural disasters in the region, we talk about always being prepared. In Port Coquitlam, one of our disasters could happen at the railyard because we have the biggest railyard in British Columbia," he said.

Moore added that he's lived in the city his whole life and nothing like this has happened before.

"Last night, we saw that some things can happen," he said.

Farnworth said he also had questions: "What protocols were not followed? How did this happen? How do we make sure it does not happen again?"

He said he expects a full investigation to be conducted by the Transportation Safety Board.

Update 9:55pm CP Rail Fire is under control. Fire crews remain on scene & are monitoring. Those evacuated outside of 800 meter radius may return home.This is north of the Lougheed Hwy & between Shaughnessy & Oxford. Reminder all residents to please stay inside & avoid the area. pic.twitter.com/4wutWgQy0t — City of PoCo (@CityofPoCo) January 23, 2018

Update: Tanker truck carrying ethanol gas hit a CN Rail Car which is the cause of fire. We can report the driver & CP Rail crew are all safe. No injuries. @CQRCMP evacuating area 800 meter radius of site. Confirmation from CN Rail there are no toxic materials being carried. pic.twitter.com/pOGOQYmJ2f — City of PoCo (@CityofPoCo) January 23, 2018

Foam truck and trailer with police escort on its way from @City_Abbotsford. Stay safe everyone! https://t.co/QGljSF5hkp — Henry Braun (@MayorHenryBraun) January 23, 2018