Carles Puigdemont, leader of the regional government, defied Madrid on Friday by setting a date for the vote even though it has been ruled illegal by Spain's Constitutional Court.
"We will vote, even if the Spanish state doesn't want it," Guardiola told the crowd in Catalan, Spanish and English.
"There is no other way; the only possible response is to vote," he added.
As Puigdemont looked on, Guardiola also called for the international community's support against "the abuses of an authoritarian state".
While the city authorities estimated that 30,000 people attended the rally, a separatist source put the figure at 47,000.
"I think independence is the only solution," Ramon Fon, a retired 67-year-old at the rally, told AFP.
"I want the referendum as a first step, and if the majority shares my opinion, then to win independence," he said, the starred flag of Catalonia draped across his shoulders.
The latest regional government poll found that 73 percent of Catalans were in favour of holding a referendum similar to the one held by Scotland in 2014 - though that one had the approval of the British government.
But the same poll found that 48.5 percent of respondents opposed independence, with 44.3 percent in favour.
In 2014, Catalonia held a non-binding vote in which more than 80 percent of those who cast a ballot chose independence, though just 2.3 million out of 6.3 million eligible voters took part.
The wealthy region of 7.5 million people is fiercely proud of its language and customs, and has long demanded greater autonomy from Madrid.