I arrived at the polling station on the night before Catalonia was set to vote in a contested referendum on the region’s independence from Spain. A Spanish court had declared the referendum illegal, and Madrid had sent thousands of riot police to Catalonia to shut down the vote. By midnight, workers at the polling station closed the building’s corrugated metal gate and sealed us in until morning, or until the police arrived. Inside, we waited for whichever came first.

The vote was organized in secret. The organizers spoke and texted in code: In this polling station — a community center in Barcelona, called Foment Martinenc — and others in the area, ballot boxes were called pizzas and the ballots, napkins. The government representative who officially opened the voting center was called “la pizzera”the pizza maker. The organizers who drove from polling station to polling station, to make sure each center had enough pizza and napkins, were called Telepizzas, after a cheap pizza delivery chain. Central Barcelona was divided among five Telepizzas.

When Catalonia voted on Sunday, October 1, ordinary voters in polling centers across the region used unconventional tactics to organize a referendum in the face of a heavy crackdown from the central Spanish government. It was a day of tension and drama, as Catalans voted for seccession by 90 percent (though most “no” voters abstained), and Spanish police reacted with force. This week, Catalan President Carles Puigdemont said he had the mandate to declare independence for the region and signed a declaration doing so — but soon after he suspended the effects of the referendum in favor of dialogue with Spanish authorities.

The October 1 clashes drew international attention to the referendum. But Catalan citizens had been preparing this vote for months.

The weekend before the referendum, police in Catalonia were given an order to shut down spaces to be used as polling stations. In response, ordinary citizens began occupying places like Foment Martinenc to keep them open. At another nearby polling station in Barcelona, an elementary school, organizers spontaneously held a weekend full of events and invited residents to camp out at the school. In a nearby city, voters organized a weekend-long tournament of rock-paper-scissors, advising participants that it might last a while, and to bring camping gear. Others were more direct, calling for a “territorial defense” of voting centers. Whether subtle, absurd or explicit, the idea was clear, said Lluís Rotger, an organizer at Foment Martinenc: “any activity to keep the polling stations open.”

Ballots and ballot boxes were targets for Spanish police in the lead-up to the vote. Police raided Catalan media, print shops, and other businesses in search of voting materials, seizing millions of ballots and hundreds of ballot boxes in each bust. After the initial seizures, the Catalan government ordered new ballot boxes from China to be delivered to a city in southern France, where ballots were being printed. Activists then drove the voting materials across the border into Spain and hid them however possible.

“People hid the material in their houses, cars, underground — it was up to their imagination,” Rotger told me. He explained that, among organizers, information about the vote was given out on a need-to-know basis. “Even the ballot boxes,” he said, “I didn’t know who had them, nor when they would arrive.”

Foment Martinenc is in a quaint residential neighborhood just outside the center of Barcelona. On the morning of the vote, the center was buzzing with activity. Poll workers opened the metal gate at 5 a.m., and a large crowd of people had already gathered outside. It was still dark out, and it was raining. The police were due to begin evicting polling stations one hour later, and organizers were rushing to prepare the space.

But where were the ballot boxes? Another organizer at Foment, Daniel Rofín, said he had no idea. Because the referendum organization was so secretive, Rofín explained, neither did anyone else at the polling station.

Soon there was a commotion outside, and a small sedan pulled up to the entrance of Foment. The crowd outside parted to make a path to the door. Two women opened the car’s trunk, pulled out four large masses wrapped in black trash bags, and shuttled them inside. Both women quickly got back in their car and sped away. The pizzas had arrived.

Two people bring in ballot boxes as crowds gather outside Escola Industrial of Barcelona school on Oct. 1, 2017 in Barcelona, Spain.

Photo: Chris McGrath/Getty Images

The organizers of the referendum in Catalonia had the odds stacked against them from the beginning. As they laid out plans for a vote, a Spanish court declared it unconstitutional and ordered police to seize voting materials. Soon after, Spanish military police arrested 14 Catalan government employees, effectively decapitating the official organization of the vote. After the arrests, Spanish press ran with headlines that the referendum had been “disassembled” and “neutralized,” and that “democracy had been restored in Catalonia.”

But the preparations continued, and so did the crackdown. Police blocked 140 pro-referendum websites and prohibited the national post office from mailing any election materials. The weekend of the referendum, three-fourths of all Spanish riot police were in Catalonia. The night before the vote was to take place, Spanish military police raided the Catalan government’s data and digital communications hub. Their objective was to take offline the Catalan census and voting rolls, as well as the webpages for the voting centers. That night, a government spokesperson in Madrid announced that the referendum had been “nullified.”

And yet, on October 1, Catalonia held a referendum. The vote was plagued with technical and logistical issues and boycotted by a large segment of the population, but many others were able to cast a vote. People waited in line for hours to do so while Spanish police went from location to location in a brutal operation that injured over 800 voters and closed nearly 100 voting centers. Social networks were saturated with photos and videos of police wielding nightsticks at unarmed protesters and bloodied faces outside public schools, and then of police walking away with voting materials.

At Foment Martinenc, after a few technical hiccups, voting started around 10:30 a.m. and lasted until the night. Poll workers made sure to keep a large group of people outside the voting center throughout the day, made up of those who had already voted, or those still waiting to do so.

“The idea was to always have people outside protecting the door,” Rotger explained. “Whenever we thought Policía Nacional or Guardia Civil might come, all the old people and kids were brought inside.”

“The first people they’re going to beat are the ones outside,” he added.

The organizers at Foment had different plans in case the police showed up. They had found hiding places for the ballot boxes inside the community center. Another plan was to smuggle the ballot boxes out of Foment in trash bags and to hide them in a nearby shop. Rotger says that he even brought a large hiking backpack with him. If the other options didn’t work, he planned to just grab the votes and run.

Such schemes were enacted all over Catalonia. In one town, activists hid the ballot boxes and started playing dominos when police arrived. In another, the vote recount was held in a church during mass.

At Tomás Moro, a school in the outskirts of Barcelona, poll workers hid the real ballot boxes and used two ballot boxes full of blank paper as decoys for the police to take.

“The police came with six vans and broke open the two doors [to the school] with crowbars and hammers,” recalled Anna Sajurjo, one of the poll workers present. “They took the two ballot boxes that were on the tables, full of blank votes.” Once the police left, Sajurjo added, voting resumed at Tomás Moro.

Even Puigdemont, the Catalan president, had to trick the Spanish police in order to vote. A helicopter from the military police was following his convoy of cars as he went to vote. Reports later surfaced that the convoy stopped under a bridge so the president could switch cars and go cast his ballot in another town, without alerting the police that were hovering above.

The Spanish police never showed up at Foment Martinenc, though there were regular visits from the Catalan police, called the Mossos d’Esquadra. Early in the morning, two Mossos officers walked toward the community center, one holding a document in his hand. As the police approached, the crowd linked arms and began shouting, “You will not pass.” After a few seconds, the police turned around and walked away. The Mossos would repeat this exercise once every two hours throughout the day.

Josep Lluís Trapero, head of the Mossos d’Esquadra, had ordered police to evict voting centers, following the court order, but told them not to use violence and not to not disturb public order – in contrast to the behavior of the Spanish forces. After the referendum, politicians in Madrid were quick to criticize the Mossos for not acting more aggressively, and a Spanish court has said publicly that it is investigating Trapero for sedition.

Daan Everts, a former Dutch ambassador who has monitored over two dozen elections around the world, said that “the use of force displayed by the Spanish police has no place in established democracies.” Everts, who brought a team of 20 observers with him to Catalonia in September, said he has never seen anything like this month’s referendum.

“It has been exceptional in all aspects,” he said. “There was very active prevention, prohibition from the Spanish government, so nothing was normal.”

Sitting in his temporary office in a posh neighborhood in Barcelona, Everts rattled off a laundry list of technical issues with the vote. The Catalan election commission worked in secrecy. There was little transparency in the voting protocols. Poll centers were intermittently open and closed due to technical issues, and most were missing some essential voting materials at points throughout the day.

In one-quarter of the polling stations visited, Everts said, voting had to be stopped temporarily so poll workers could hide voting materials from the police.

Still, Everts was quick to add what his team of observers didn’t see: evidence of vote fraud, in the form of ballot-stuffing, doctoring vote counts, and other efforts to tip the final result. But because of opposition from the Spanish government, he said, “It was very messy by definition.”

People celebrate after the closing of polling stations outside the “Espai Jove La Fontana” (La Fontana youth center) on Oct. 1, 2017 in Barcelona. Spanish riot police stormed voting stations as they moved to stop Catalonia’s independence referendum, and least 92 people were confirmed injured as hundreds tried to prevent the polling stations from being closed.

Photo: Pau Barrena/AFP/Getty Images

After spending most of the day of the vote at Foment Martinenc, I decided to go visit other polling stations in the neighborhood. It was around 7 p.m., one hour before the polls were officially supposed to close.

There were around 200 people gathered outside another nearby polling center when David Fernandez, a former local politician from a far-left separatist party in Catalonia, came outside. The crowd cheered. “We have to defend the votes, and we need you to help. Let’s go for a walk. Don’t ask questions,” Fernandez told the group, who all seemed to instantly understand what was about to happen.

A line of people then exited the school, carrying multiple ballot boxes among them. The crowd massed around them and began chanting protest slogans as they walked. As people on the balconies above us started filming and taking photos, chants of “we voted” and “the streets will always be ours” slowly changed to one unified chant of “don’t film!” The crowd seemed to know how exposed they were.

This was the fourth escape plan among the polling stations in the area, Rotger, the poll worker at Foment Martinenc, explained. One of the stations was on a narrow pedestrian street and had only one entrance. Poll workers all assumed that the Spanish police would raid while they were counting votes and decided to stop voting an hour early and move all of the ballot boxes to the most protected polling station. As polling workers carried the last boxes into the voting center to be counted, a large crowd swarmed in front of the door, blocking the entrance. The riot police never showed up.

The contested vote set off a week of protests. The day after the referendum, people clogged the street outside the headquarters for the Spanish police in downtown Barcelona. Flag-wielding separatists squared up against Spanish riot police with shields and tear gas cannons, until local police came to diffuse the situation. The next day, Catalan labor unions called a general strike, and for a day the streets of every Catalan city were packed with people protesting police violence. The following weekend, 350,000 Spanish nationalists filled the streets of Barcelona, many having bussed in from all over Spain. While most separatist demonstrators have been peaceful, even in the face of Spanish police provocation, the nationalist march was marked by violent clashes with bystanders and the occasional fascist flag and Nazi salute.

The tone of the protests was a far cry from the scene at Foment Martinenc on the eve of the referendum. There, there were no flags and no talk of political parties. The center was filled with Catalans of all political stripes; people seemed more concerned with their ability to vote than what would happen afterward. Yet as we waited, a few people watched videos that had been shared on social media days earlier, of military police leaving from cities all over Spain to come stop the vote in Catalonia. In the videos, crowds had gathered to see the police off, waving Spanish flags and chanting, “Go get them!”

A few of those watching, in a moment of introspection, wondered out loud when it had become about “us” and “them.” The chanting crowds in the video seemed a harbinger of the clashes that were to come.

Top photo: People rest inside a would-be polling station at a school in Barcelona, on Oct. 1, 2017, to prevent the police from sealing it off in a referendum on independence for Catalonia banned by Madrid.