The Cass County sheriff's office said it was "strongly recommending" that people in the town of Casselton and anyone living 5 miles to the south and east evacuate. A shelter has been set up in Fargo, which is about 25 miles away. Casselton has about 2,400 residents.
The sheriff's office said the National Weather Service was forecasting a shift in the weather that could increase the risk of potential health hazards.
"That's going to put the plume right over the top of Casselton," Cass County Sheriff Paul Laney said at a news briefing.
As many as 10 cars out of more than 100 caught fire when the BNSF Railway Co. train left the tracks about 2:30 p.m. Monday. No one was hurt.
The cars were still burning as darkness fell, and authorities said they would be allowed to burn out.
Authorities hadn't yet been able to untangle exactly how the derailment happened, but a second train carrying grain was involved. BNSF spokeswoman Amy McBeth said the train carrying grain derailed first, then knocked several cars of the oil train off adjoining tracks.
The National Transportation Safety Board said Monday night it has launched a "go-team" to investigate the accident.
Ryan Toop, who lives about a half-mile away, said he heard explosions and drove as close as about two city blocks to the fire, which erupted on a day when temperatures were below zero.
"I rolled down the window, and you could literally keep your hands warm," Toop said.
The derailment happened amid heightened concerns about the United States' increased reliance on rail to carry crude oil. Fears of catastrophic derailments were particularly stoked after last summer's crash in Quebec of a train carrying crude from North Dakota's Bakken oil patch. Forty-seven people died in the ensuing fire.
The tracks that the train was on Monday pass through the middle of Casselton, and Cass County Sheriff's Sgt. Tara Morris said it was "a blessing it didn't happen within the city."
Morris said it could take up to 12 hours before authorities could get close to the fire. About 80 of the cars were moved from the site. Jeff Zent, a spokesman for Gov. Jack Dalrymple, said the National Guard was on alert if needed.
Temperatures were forecast to drop to minus 20 in Cass County overnight.
"Of course, Mother Nature, being North Dakota, it has to be one of the coldest nights of the year. It's deadly cold out there tonight," Laney said.
Mayor Ed McConnell said he didn't want any residents sleeping in their vehicles.
"All the experts say it can be a hazardous situation to their health," McConnell said. "We're going to try to get everybody out of the town."
In the initial hours, authorities told residents to stay indoors to avoid the smoke.
Hannah Linnard, 13, said she was in the bedroom of her friend's house about half a mile from the derailment, wrapping late Christmas presents.
"I looked out the window and all of a sudden the train car tipped over and the whole thing was engulfed in flames and it just exploded. The oil car tipped over onto the grain car," she said. Hannah said she could feel the warmth even inside the house.
Terry Johnson, the manager of a grain dealer less than a mile from the derailment, said he heard at least six explosions in the two hours following the incident.
"It shook our building and there was a huge fireball," he said.
North Dakota is the No. 2 oil-producing state in the U.S., trailing only Texas, and a growing amount of that is being shipped by rail. The state's top oil regulator said earlier this month that he expected as much as 90 percent of North Dakota's oil would be carried by train in 2014, up from the current 60 percent.
The number of crude oil carloads hauled by U.S. railroads surged from 10,840 in 2009 to a projected 400,000 this year. Despite the increase, the rate of accidents has stayed relatively steady. Railroads say 99.997 percent of hazardous materials shipments reach destinations safely.
Associated Press writers James MacPherson in Bismarck, N.D., and Dirk Lammers in Sioux Falls, S.D., contributed.