A weekend train derailment and fire on the tricky Tehachapi Loop east of Bakersfield sent toxic smoke skyward, prompting evacuation of nearby residents.

No one was hurt.

The freight route between Bakersfield and Barstow remained shut Sunday night, backing up at least 18 trains. A blaze remained active inside the tunnel where the incident occurred.

Railroad officials hoped to have a coastal detour operating sometime today, while fire officials hoped to contain the remaining fire by midnight Sunday.

Whether the derailment or fire came first still wasn't known Sunday night.

Carin Enovijas, 45, said her family was woken up by sheriff's deputies around 11:30 p.m. Saturday and told to leave.

"The deputy came to the door wearing a mask," said Enovijas, who remained at a Tehachapi hotel Sunday night with her husband and children, aged 6 and 8.

Having small children -- and the flu -- made the Fairfield Inn more appealing than a shelter set up at Tehachapi High School, she said.

About a half-dozen families within a mile of the accident site were told to evacuate Saturday night, said Kern County Fire Department Engineer Justin Corley.

On Sunday, officials expanded the evacuation radius to two miles. But residents in the expanded area didn't have to leave their homes -- they were simply advised to stay inside and shut windows and doors, Corley said.

The BNSF Railway train derailed around 9:30 p.m. Saturday in a tunnel outside Keene, about 30 miles east of Bakersfield.

A tanker car carrying denatured alcohol was allowed to burn out overnight on its own.

The fire spread to two other cars, one holding corn meal, the other polystyrene plastic pellets.

The plastic fire sent black smoke into the sky Sunday and required a more aggressive response than the alcohol, said the fire department's Corley. Fire crews doused the car with twin sprays of foam after it was pulled from the tunnel.

County fire crews worked with railway firefighters, county environmental health staff and specialized contractors at the accident scene Sunday. Huge trucks and earth movers carved a muddy swath through a farmer's field next to the tracks. The surrounding hills, green from recent rains, were brightened by occasional patches of colorful wildflowers.

Brian Pitts of the Kern County Environmental Health Department said his main concern was keeping people away from the smoke. He saw little risk left at the accident site.

"We think everything burned up," he said of potential environmental toxins.

Lena Kent, spokeswoman for BNSF, said 18 of the railway's trains were backed up on the single-track route Sunday. With the fire still alive inside the tunnel, officials didn't know the full extent of damage.

The incident will be investigated jointly by BNSF, which owns the derailed train, and Union Pacific Railroad, which owns the tracks.

The Tehachapi Loop, where the accident occurred, is a popular attraction for train buffs. A looped section of track that allows travel over the Tehachapi Pass is considered an engineering marvel. The front of a long train will pass over its rear cars as it travels the segment. Enthusiasts travel to Keene or an overlook off Woodford Tehachapi Road to watch trains roll up and down the helix.

Aaron Hunt, spokesman for Union Pacific, said the railway will reroute freight trains through coastal tracks that run through the Ventura, Santa Barbara and San Luis Obispo areas. The detour should be fully functional by Monday night, he said.

Neither Hunt nor Kent could say when when the inland route might reopen.