The people of Catalonia in north-eastern Spain are voting in a disputed and non-binding poll on independence.
The Spanish judiciary has ruled the vote unconstitutional but Catalan leader Artur Mas warned against any attempt to disrupt it.
Spain's constitutional court suspended earlier plans for a referendum on secession.
Prime Minister Mariano Rajoy said the vote would have no effect and urged the region to return to "sanity".
Voters will be asked whether they want a Catalan state and whether that state should be independent.
More than 40,000 volunteers are helping to set up and run the informal exercise.
As of 18:00 local time (17:00 GMT) - two hours before the close of polling, 1,977,531 had voted, according to the Catalan government.
'Attack on democracy'
Catalonia is a wealthy region of 7.5 million people and contributes more to the Spanish economy than it gets back through central government funds. Economic and cultural grievances have fuelled Catalan nationalism.
Pro-independence supporters have campaigned earnestly for a big turnout.
The BBC's Europe correspondent Chris Morris says many Catalans have always felt that they do not quite fit in a unitary state.
He says there is a long history of support for winning independence from Spain, or at least much greater autonomy within it.
At the scene: Patrick Jackson, BBC News Barcelona
This was the symbolic independence vote they tried to ban but Spanish legal hurdles could not stop Catalonians from turning out.
Barcelona's CIC secondary school is teeming with people of all ages, elbow to elbow, undeterred by the rain.
Patiently they queue to register before heading for one of the nine precious cardboard ballot boxes, at tables around the school, supervised by happy volunteers.
Most voters I speak to favour independence but there are others voting No, exercising their right to vote in defiance of what they see as Madrid's intransigence.
Radiating good humour, one couple told me they were voting different ways. Lilian Subietas, proud mother of four young Catalans, said she was persuaded to vote Yes while her husband, airline pilot Cesar Saiz, said he was voting No because Europe needed to stay together.
This week, the Constitutional Court demanded the vote be suspended.
But Catalonia's government insisted it went ahead with its "consultation of citizens", with no official electoral roll.
Mr Mas has warned the Spanish government against any attempt to halt the vote.
He said: "I don't know what they will do, it does not depend on us, but if they have a minimum of common sense I think any action out of the ordinary would be a direct attack on democracy and a direct attack on fundamental rights."
Mr Rajoy urged a return to sanity and for talks "within the legal framework of the constitution".
He said the vote would be "neither a referendum nor a consultation nor anything of the sort".
He added: "What is certain is that it will not have any effect."
- Roughly triangular region in Spain's far north-east corner, separated by the Pyrenean mountains from southern France
- One of Spain's richest and most highly industrialised regions
- Many Catalans think of themselves as a separate nation from the rest of Spain
- This feeling is fed by memories of the Franco dictatorship, which attempted to suppress Catalan identity
The Libres e Iguales (Free and Equal) group, which opposes the vote, held protests in dozens of cities.
One protest in Barcelona witnessed minor scuffles but no arrests.
Rallies in favour of the vote have also been held.
Murial Casal, the president of Omnium Cultural, which promotes Catalan culture, told a gathering on Friday: "Call your parents, your friends and your neighbours and tell them that they have to vote."
Catalonia adopted a charter in 2006 giving it "nation" status but this was overruled by the Constitutional Court in 2010.
Independence supporters hope that a strong vote of support will put more pressure on the central government to open negotiations over more tax and political autonomy, ultimately leading to a full-blown independence referendum. They say that support from more than 1.5 million Catalans would add weight to their cause.
Many of those opposed to independence are not expected to participate in the poll.