Martha's post explains it well.
There are indeed split opinions in the Catalan population, previously around 50/50. There is also a colossal amount of political fuckwittery going on in both Madrid and Barcelona.
Had Madrid accepted the legitimate desire of many Catalans to hold a real referendum on this issue at any point before yesterday, I believe the result would have been against independence. But the Spanish government has repeatedly refused to budge an inch, claiming that it is unconstitutional (true) and that the constitution can't be changed (false; they've done it before) and that any such referendum, should it happen would have to allow all of Spain to vote. Which is no-one's idea of self-determination, outside of the delusional "kindly authoritarian" self-image the Spanish government seems to have. Why the hardline attitude? Because they need the support of the anti-Catalan, hard-right element within Spain that constitutes the base of the ruling PP (Partido Popular) and that element demands a "no surrender" attitude when it comes to threats to the motherland, which is how they view any referendum at all.
So the Catalan separatist politicians, after scraping a tiny majority of seats at the last regional elections (run as a plebiscite) pushed through a unilateral "process", which included a referendum they knew to be illegal, to be followed by a declaration of independence. Like Madrid's "all Spain" referendum, the separatists knew that this too was bullshit and rigged because it excluded many Catalans, who refused to vote in it. The separatists remained, however, at all times open to a real referendum, knowing it would never happen due to Madrid's intransigence.
The Catalan leaders have made grave mistakes. They should have accepted the narrow win in those regional elections as motivation to get back out there and win over the undecided, of whom there were many, until yesterday. With a 66%+ popular vote, their position for holding a unilateral referendum would have been very strong. However, they wanted to rush their agenda through. This was cynical, or naive, take your pick. What they haven't ever done is sanction violence. They also represent a very legitimate grassroots movement of at least half of all Catalans.
Here's where the murky grey areas separate into black and white, right and wrong. The PP yesterday sent in the police as troops, to assault people voting peacefully (albeit pointlessly or at best symbolically) in a pseudo-referendum that the PP said wasn't happening and didn't count. Instead of ignoring it, the government applied state violence on a large scale. It was a PR own goal of enormous proportions. It has all but ended the debate and made further, worse violence all but inevitable. The violence went down well with many right wing Spaniards, but it tipped international opinion against Madrid and turned millions of Catalans into reluctant independence supporters, regardless of the consequences.
Yesterday I watched 12 vans of armed and masked men storm the primary school where my children play at weekends, and attack my neighbours. My wife's uncle, an elderly, gentle, cardigan-wearing teachers was struck and thrown to the ground. It felt like an invasion. And the public response has been near-universal: fuck you, Spain.
It's tragic. And it's going to get worse.