BARCELONA — A confrontation in Catalonia drew closer on Saturday, as people camped out in scores of polling stations throughout the region, intent on keeping them open for Sunday’s referendum in defiance of the Spanish government’s orders.

In the polling stations, mostly public school buildings, there was a festive atmosphere, with crowds of people singing protest songs, playing board games, taking dance classes, playing table tennis and otherwise passing the time until 6 a.m. on Sunday, the deadline set by the police to evacuate the buildings.

It remained unclear how many polling stations will open. Spain said on Saturday that only 163 voting sites were occupied, far below the 2,315 stations that Catalonian officials had promised. And no one knows what the police will do if, on Sunday morning, the people inside refuse to leave.