"The company has decided to cease its operations as a measure of caution and safety," Spanair said in a statement late on Friday, citing a poor financial outlook.
Its last scheduled flight landed half an hour after the statement was issued leaving rivals such as Iberia, Vueling and Easyjet to take passengers stranded by the airline, which runs flights within Spain and to Europe and Africa.
Spanish media said at least 22,000 passengers were affected over the weekend.
Airports authority AENA said special lounges had been allocated for Spanair customers, who were being allocated to other airlines, but they had to buy their tickets.
"They told me now I have to buy another ticket. I have no money. How can I?" one angry man told Spanish television.
The public works ministry said there were 647 Spanair flights cancelled between Saturday and Monday while yesterday about 170 passengers were stuck at an airport in Mali, a similar number in Gambia and others in Morocco.
The ministry did not have figures for the number of people stuck in its European destinations such as France and Germany.
Spanair spokespeople were not available on Saturday to confirm the figures.
The airline said in its statement: "The Spanair management regrets this and apologises to all those people who are affected by this situation."
The Spanish government said it was taking disciplinary action against Spanair for breaching rules on continuity of services and passengers' rights in the course of its sudden shutdown, and may fine it up to 9 million euros.
The public works ministry said in a statement it was launching "sanction proceedings for two serious breaches of the Air Safety Law which could lead to fines of 4.5 million euros in each case."
"The ministry will not cease until those who failed to fulfill the norms and trampled on the rights of citizens takes full responsibility," public works minister Ana Pastor told a news conference.
Spanair, which was founded in 1986 and has about 2,000 staff, had tried to survive by a tie-up with Qatar Airways which fell through.