Spanish airspace has reopened following a strike by air traffic controllers that has left thousands of British holidaymakers stranded in Europe and North Africa.

Airlines cancelled flights in and out of the country after industrial action affecting 330,000 international passengers. The Spanish government declared a state of emergency and threatened the strikers with imprisonment.

The reopening of airspace was confirmed by the Spanish air traffic control agency, Aena. Passengers are being advised to contact their airline before travelling.

Earlier today the deputy prime minister, Alfredo Perez Rubalcaba, said the controllers – who called in sick en masse – had been ordered back to work and could face charges and jail under the military penal code if they refused.

"We said that if the situation in the airports did not normalise we would call a state of emergency. It's clear that the situation has not normalised," Rubalcaba said after an emergency cabinet meeting.

Eight Spanish airports, including Madrid, closed across the Spanish mainland and flights from the Canary Islands, as well as Portugal and Morocco, were cancelled.

Airlines including Iberia, EasyJet and Ryanair cancelled all Spanish flights until Sunday morning. The country's airspace has been taken over by Spain's military in an attempt to get flights moving during a holiday long weekend in Spain. Spanish soldiers are not trained on how to use civilian airport equipment but instead are in place to give orders to controllers who did report for work.

Travel association Abta said airlines had a legal duty to care for passengers who were not able to return to the UK as a result of the Spanish dispute. Abta spokesman Sean Tipton said: "It is a pretty quiet time of year but there will be thousands of British people stuck over there. There have been widespread cancellations. Customers due to travel out today need to keep in contact with their airline or tour operator."

Tipton said customers who were yet to travel to Spain would be offered either the option to rebook their flights or a refund. Tour operators would be making efforts to reschedule flights for those on package holidays.

Some British passengers have already had their return home delayed due to snow and ice in the UK.

The British transport secretary, Philip Hammond, said the industrial action was unexpected. "We had no advance warning of this action in Spain. Clearly the airports are, in any case, suffering from delays and disruption due to bad weather," he told Sky News.

Keith Beevor, of Penrith, Cumbria, who has been stuck in Alicante for two days, said he had no idea when he would be able to return home. He told the BBC: "People are quite calm at the moment. But things might change if it's a long time before we can get away."

Iberia said in a statement that passengers should not go to airports, with those already there advised to go home or to hotels. Its flights are due to resume at 6am on Sunday.

In a message posted on its website Ryanair said: "Ryanair has been forced to cancel all flights to and from all Spanish airports (including the Canary Islands) and all Portuguese airports today.

"Our first wave of flights to and from Spain tomorrow morning is planned to operate but, as many Ryanair aircraft and crews are out of base as a result of this walk-off by Spanish ATC, these flights are at risk of delay or cancellation."

EasyJet cancelled all flights to and from Spain, the Canary Islands, Gibraltar, Portugal and Morocco for the day.

A spokesman added: "It is likely that there will be further disruption into tomorrow. A further update will be issued later today regarding tomorrow's schedule."

British Airways told its passengers: "We will be doing all we can to minimise any disruption as a result of unplanned industrial action by air traffic control staff in Spain.

"We are advising passengers to check ba.com before they leave for the airport to check the status of their flight."

Passengers due to travel from Heathrow and Gatwick have generally heeded advice not to go to the airport and to contact their airline instead.

Luton Airport has advised passengers that flight disruption is expected until 6pm at the earliest.

Ten flights from Manchester were cancelled because of the strike, an airport spokeswoman said, but they were keeping "fingers crossed" that the action would be over shortly and flights could return to normal.

Passengers from Manchester were advised to contact their airlines or check online that the flight was still as scheduled.

A spokeswoman for Liverpool John Lennon airport said 16 outbound flights were cancelled due to the strike and advised passengers to check with their airlines before setting off.

A spokeswoman for air traffic body Nats said the situation should now being to improve.

Controllers abandoned their posts amid a lengthy dispute with the air traffic authority, Aena, over working hours and conditions. The strike also came hours after the government approved measures to partially privatise Spain's airports and hand over management of Madrid and Barcelona airports to the private sector.

About 15 of 77 controllers scheduled to begin a shift at Madrid airport turned up for work, the national air traffic control agency Aena said.

Police handed out blankets at Madrid's Barajas airport to travellers who had not been able to find or afford hotel rooms for the night.

The walkout brings to a head a year-long dispute and has also closed key tourist airports in Ibiza, Palma de Mallorca, Menorca and four airports in the Canary Islands.

Aena said the Canary Islands airports had begun operating this morning and some flights were landing and taking off at Barcelona airport as well as at some Andalucian airports.