In a protest that echoed recent political upheavals in former Soviet bloc countries, demonstrators bore orange flags and flowers.
Organisers said they hoped 15,000 people would turn out although some estimates suggested the crowd was bigger.
Some in the crowd shouted “Resign!” and “Freedom!”.
“Let no one think that this struggle will end. We will wage it until the end," Ali Kerimli, leader of the Popular Front, one of the three parties in the Azadliq opposition bloc, told The Associated Press. Azadliq and other opposition groups were taking part in the rally.
"We are protesting because the election was not fair," Fatma Mammedova, 43, said. "We want the world to help us."
Police warned they might break
up the protest
Security was tight with about 800 riot police, equipped with shields and truncheons, standing guard around the square. Opposition youth activists chanted: "The police are with the people!"
Azerbaijan's authorities warned that if the rally overstayed its legal permit, set to expire at 1300 GMT, the protest would be forcibly dispersed.
Official results show the ruling party of authoritarian President Ilham Aliev having won the most seats in last Sunday's vote, but the opposition has alleged widespread fraud.
International observers such as the Council of Europe, meanwhile, have declined to endorse new elections, instead calling for officials responsible for the alleged fraud to be punished.
There is resentment at poverty
as oil wealth increases
Election authorities said Saturday that a new vote would take place in three districts where pro-government candidates had won seats. A seat in another district has already been awarded to Kerimli after a recount.
Georgia’s "Rose Revolution" in 2003 and Ukraine’s "Orange Revolution" last year both forced out governments accused of electoral fraud.
The Azerbaijani opposition, which lacks the popular support that anti-government forces enjoyed in Georgia and Ukraine, warns that Islamic radicalism could spread should they fail to dislodge the government.
However, despite resentment at widespread poverty amid growing oil wealth, there is no sign of a rise in Islamic fervour in this strongly secular Muslim country.