Pro-independence parties in Spain's Catalonia region have won an absolute majority in regional elections.
The main separatist alliance and a smaller nationalist party won 72 seats in the 135-seat regional parliament.
However, the pro-independence parties fell just short of getting 50% of the vote, winning 1.9 million out of 4 million ballots cast.
The separatists say the victory gives them a clear mandate to form an independent Catalan state.
Spain's central government in Madrid has pledged to challenge any unilateral moves towards independence in court.
The "Junts per Si" ("Together for Yes") alliance won 62 seats. If it combines with the far-left separatist CUP party, which won 10 seats, it will be able to form a parliamentary majority.
"We have won," Catalan regional President Artus Mas told his cheering supporters late on Sunday.
After a celebration rally, the pro-independence camp's leaders said they would now proceed towards the creation of an independent Catalan state.
"We have a clear, absolute majority in the Catalan parliament to go ahead," Mr Mas said.
Analysis: BBC's Tom Burridge, Barcelona
The result was more ambiguous than the positive rhetoric suggests. The pro-independence camp continues to say they are ready to break away from Spain, even in the face of strong opposition from the Spanish government.
But they know that would be controversial and complicated. In truth, their aim is still to get a legally-recognised referendum.
So they will continue to pile the pressure on the government, safe in the knowledge that a Spanish general election is less than three months away.
A more fractured political landscape at the national level suggests there will either be a change in who holds power, or at least the position of the governing Popular Party (PP) will be weakened. And that might lead to a change of stance over the Catalan question in Madrid.
Pablo Casado, spokesman for Spanish Prime Minister Mariano Rajoy's PP party, argued that the separatists had "failed" by not securing a majority of votes.
"This election should serve to end the independence debate once and for all," he told the AFP news agency.
Spain's government has consistently dismissed any secession plans as "nonsense".
The pro-independence parties said ahead of the vote that they considered it a de facto referendum on independence from Spain.
They argue that the Spanish government has consistently refused to allow a legally recognised referendum to take place, ignoring an unofficial vote backing independence in November 2014.
Opinion polls suggest a majority of Catalans favour a referendum on independence but are evenly divided over whether they want to secede.