The Spanish government declared a "state of alarm" yesterday for the first time in three decades, assuming sweeping powers that allowed the military to take control of the country's airspace and order Spain's striking air traffic controllers to work or face prison.

The extraordinary move by the Socialist government of prime minister José Luis Rodríguez Zapatero was expected to allow some of the thousands of British tourists trapped in Spain to start returning home this morning.

Up to 20,000 were trapped by the sudden closure of local airspace on Friday afternoon after Spain's air traffic controllers walked out in a dispute over working hours. Military law was applied from midday yesterday, allowing them to be arrested and charged if they did not return to work. Spain's military code allows sentences of up to two years for those who disobey an order to work from the defence ministry. "If they do not go to work, they will be committing a crime of disobedience according to the military penal code," the deputy prime minister, Alfredo Pérez Rubalcaba, warned after an emergency cabinet meeting.

The measure appeared to work. By late yesterday evening, Rubalcaba said that more than 90% of the controllers had returned to work. But he added that it could still take up to 48 hours for air traffic to return to normal after Spanish airspace reopened during the afternoon. It was also unclear if strikers would seek fresh ways to continue their protest.

Airlines warned that the chaos would take several days to sort out. Airlines Ryanair and Iberia said that they would not resume flying until this morning.

British holidaymaker Robert Dearman had been waiting for more than 24 hours to fly back to the UK from Tenerife after undergoing emergency treatment for pneumonia and a cardiac condition while on holiday. He and the British doctor who had flown out to oversee his repatriation had left hospital for the airport on Friday. "The doctors and medical staff over here in Spain saved my life, and now the air traffic controllers here are doing their best to kill me off," Dearman said. "I'm running low on medication."

The sweeping powers assumed by Zapatero's government came in response to the popular rage with which Spaniards reacted to a flash strike at the beginning of a long holiday weekend. It was the first time the emergency powers had been used since the law regulating them was approved in 1981. The decree can be applied when there is "paralysis of public services".

"We are up against a group of workers who use their position of importance to defend intolerable privileges that the government cannot accept," Pérez Rubalcaba said. "They are holding the people to ransom in order to maintain their privileges."

Zapatero has taken as a model Ronald Reagan's 1981 confrontation with American air controllers, when he also sent the military in and broke the union. In a country that has 20% unemployment and is suffering massive cuts in government spending, the 2,300 well-paid air traffic controllers have become a national obsession. They earned an extraordinary average of €350,000 (£300,000) each last year, thanks to generous overtime rules. Those who worked most overtime earned up to €900,000, with 160 earning above €600,000. The government passed a law restricting overtime and tightening working conditions earlier this year.

Air force personnel had already been ordered to take over control towers on Friday night. Chaos reigned as aircraft were turned around on runways and tens of thousands of passengers were stranded, often with suitcases still inside aircraft. Thousands of people spent the night in packed terminals. Barcelona football club failed to get their players to a first division fixture against Osasuna in Pamplona, northern Spain, yesterday.

"Tourism is the biggest sector in our economy and one that was showing signs of recovery," said the secretary of state for tourism, Joan Mesquida. "This has caused huge damage." An estimated 300,000 people had been due to travel by air on Friday alone, according to El País newspaper.

"The losses are incalculable and it is money we will never get back," said a Barcelona-based hotelier, Joan Gaspar. Madrid's hotels had been fully booked for what is the most important shopping weekend before Christmas.

Indignant Spaniards called for the air traffic controllers to be punished after they claimed en bloc to be suffering too much "stress and anxiety" to work. The strike started on the same day the government approved plans to partially privatise the company that runs Spain's airports.

The cabinet also approved measures to prevent controllers claiming they had already worked all the hours permitted in their contracts for 2010.

The Spanish closures came on top of chaos already caused by snow at Gatwick and other British airports.