BUDAPEST, Hungary — A major snowstorm and violent gusts of wind forced thousands of people to spend the night in their cars or roadside buildings after being stranded on a major Hungarian highway.

Rescue officials said wind gusts of up to 62 mph and trucks jackknifed across the M1 highway between Budapest and Vienna led to the traffic jams. On Friday, rescuers cut across guardrails to allow vehicles to leave the jammed highway on makeshift roads.

Snowdrifts up to 10 feet high and the violent gusts blocked off major roads across the country and the storm also left more than 100,000 people without electricity.

Some 5,700 cars were stranded on the roads while 18 trains were stuck between stations, the Disaster Management Agency said, adding that over 100 people were injured in traffic accidents and other snow-related accidents.

So far, more than 8,000 people have taken refuge in heated buildings set up by the agency to take in stranded travelers.

Interior Minister Sandor Pinter said police and rescue units had been alerted, while military vehicles with caterpillar treads had also been called in to take part in rescue operations.

The weather conditions also led the government and several opposition parties to cancel outdoor festivities and events planned on Friday’s national holiday commemorating Hungary’s 1848 revolution against the Habsburgs.

In the south of neighboring Serbia and across Montenegro, melting snow caused rivers to burst their banks and flood some villages.