The separatist alliance's leader, Artur Mas, has said he will now push for the creation of an independent state.
His group will have a majority in the Catalan parliament if it can carry the support of a smaller separatist party.
Catalonia has 7.5m people and provides about one-fifth of Spain's GDP.
The Madrid government has reaffirmed its opposition to a vote on secession, noting that nationalists failed to get a majority of Catalonia's popular vote.
"I am ready to listen and to talk, but not in any way to liquidate the law," Mr Rajoy said in his first public remarks since Sunday's election.
"I am not going to talk about either the unity of Spain, or sovereignty."
The main separatist alliance and a small pro-independence party won 72 of the 135 regional parliament seats.
The separatists took 47.8% of votes cast.
Mr Mas's "Junts pel Si" (Together For Yes) coalition has vowed to implement a "roadmap" to achieve an independent Catalan state within 18 months.
The future of Catalonia is expected to be a crucial issue in Spain's general election in December.
The turnout of 78% was a record for a regional vote in Catalonia.
Junts pel Si won 62 seats. It can secure a parliamentary majority by combining with the far-left separatist CUP party, which got 10 seats.
Pro-independence Catalans argue that their region gets an unfair deal, contributing too much tax to Madrid in return for insufficient state investment. In terms of GDP, theirs is the richest region in Spain.
Katya Adler: Looming independence or little change?
Catalonia's quarrel with Spain explained
Independence debate gets personal ahead of Spain vote
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 to secede.
Spanish PM Mariano Rajoy says he is ready to listen to Catalonia's new regional government after the separatist victory in Sunday's polls - but will not discuss Spain's unity.