Catalonia’s regional parliament has passed a motion to establish an independent Catalan Republic.
Separatist legislators erupted in applause as the vote was approved with 70 votes in favour, 10 against and two blank ballots.
Most opposition members had left the chamber in protest moments before the vote.
Spain opposes the independence bid and the national government in Madrid is readying measures to take control of the north-eastern region.
Spanish prime minister Mariano Rajoy urged the country to remain calm minutes after the motion was passed.
Mr Rajoy made the appeal in a tweet, saying: “I call on all Spaniards to remain calm. The rule of law will restore legality to Catalonia.”
The tweet came as the Senate in Madrid prepared to approve government proposals to take direct control of Catalonia.
A majority of senators are expected to give Mr Rajoy the go-ahead to apply unprecedented measures including sacking Catalan President Carles Puigdemont and his cabinet.
Thousands of people watched the Catalan voting process and the counting live on big screens outside Catalonia’s parliament in Barcelona, and cheered and danced after the motion was passed.
Mr Puigdemont and vice president Oriol Junqueras exchanged congratulatory embraces and handshakes after the vote.