Firefighters in Whitby had a close call on Tuesday when their fire truck rolled over into a ditch. The driver attempted to avoid slamming into other vehicles after allegedly being cut off.

"He did everything in his power, and was successful in not hitting anybody else and bringing the truck to a safe landing in a ditch -- but nobody was injured," Deputy Chief Bob Mowat of Whitby Fire told CTV Toronto on Tuesday.

Witnesses told police the truck was travelling on Baldwin Street near Winchester Road with its lights and sirens on at around 8 a.m. The roads were slick from rain.

A small car cut off the massive truck. As a result, it veered into the ditch, splintering a wooden hydro pole in the process. The emergency vehicle landed on its side, trapping firefighters inside.

"I just heard a big crash and a boom and a giant like electrical spark explosion," Rennie Robichaud, a nearby resident, told CTV Toronto.

Robichaud ran to the scene and called for help along with several other witnesses. He warned people about the live hydro wires on the scene. Other firefighters arrived soon afterward.

The four firefighters from the truck were transported to hospital as a precaution but no one was seriously injured in the accident. They have all since been released.

"I felt very comfortable when they were leaving that yes, they were in good shape," Mowatt said.

Fire officials say that all firefighters were wearing their seatbelts at the time of the accident.

"The fact that nobody got hurt, they must have seen it coming and grabbed on to something real good, because they were all laying on the floor," Robichaud said. "It looked pretty chaotic in there."

Police say the cause of the accident is still under investigation, but one witness told reporters that had the driver not swerved, he would have almost certainly hit the much-smaller vehicles ahead of him.

Mowat said the driver is shaken up, "but I think more than anything, he's relieved that it could have been a lot worse."

With a report from CTV Toronto's Reshmi Nair