Yesterday, millions of Tunisians lined up – some for several hours – to vote in their country's first free election. Some voters came with their children to show them, they said, what democracy looks like. Many were also voting for the first time, having refused to take part in the masquerade that electoral politics was under the oppressive regime of their deposed dictator, Zine al-Abidine Ben Ali.

The road to the polling stations has not been easy. For weeks after the dictator Ben Ali fled to Saudi Arabia, which gave him asylum, members of his ruling party, the RCD, sowed chaos. Snipers took to buildings and shot people, and looters raided wealthy neighbourhoods and terrorised poor ones. Even after order was restored, the popular demands that were unleashed – particularly from the country's poor interior, where the revolt that turned into a revolution began in mid-December 2010 – were often difficult to manage. Economic growth plummeted, and the civil war in neighbouring Libya, where many of the poorest Tunisians work, often made things more difficult.

Tunisians weathered this, including several changes of governments, with tenacity and aplomb. This election may not be perfect – tiny opposition parties had little time to turn into mass-based organisations, restrictions on political campaigning have at times been obtuse, and the mandate of the constituent assembly is somewhat vague – but it has generated considerable enthusiasm. Even among those who distrust politicians or are unhappy not to see a more concrete windfall from the January revolution, there is a recognition that the country has already changed tremendously.

It is nothing short of a miracle to witness a country that only a year ago had one of the most repressive police states in the region now hold its freest elections. It is not just that these elections are technically sound: unlike the much-hailed polls in Iraq in the last decade, they are not taking place against a backdrop of civil war and military occupation, or with the sectarian calculations that have defined Lebanon's elections. These elections are taking place in a democratic spirit; Tunisia's parties are not backed by gangs and militias.

Ben Ali's police state took the undemocratic, but well-run, republic created by Tunisia's founding father, Habib Bourguiba, and worked to pervert it for 23 years. The corruption of his family and his cronies made a mockery of the strong work ethic of ordinary Tunisians. His pervasive, and often cruel and petty, repression, in the words of one of the country's most famous samizdat writers of the Ben Ali years, Om Zied, "put a policeman in everyone's head".

The Tunisian people now seem doubly liberated: from a nasty regime, but also from their own guilt in not confronting it earlier. Many are embracing political activism for the first time in their lives in a manner that makes the apathy often prevalent in established democracies seem shameful.

There is nervousness about the election's results, of course. It is likely that Al-Nahda, an Islamist movement that leads in the polls, will do well, disturbing the strongly secular tradition of Tunisian politics since 1956. But, significantly, there are signs that Tunisian politics are maturing: today's al-Nahda seems far from the much more conservative and illiberal Islamist movement of the 1980s, and secular parties are grudgingly recognising that their presence on the political scene is legitimate. Indeed, al-Nahda's popularity appears to be as much based on the recognition of its leaders' ordeal – killings, torture and exile – as their religious ideas. In exchange for its political acceptance by secularists, al-Nahda has largely endorsed the relatively liberal social consensus instilled by Bourguiba.

Whatever the composition of the constituent assembly, still has much work ahead to complete its transition to democracy. The constituent assembly will have to provide a better, more transparent, form of transitional justice. It must hold accountable members of the former security apparatus and the corrupt businessmen close to the regime, as well as address the economic demands of average citizens. Among the myths dispelled by the uprising is that Tunisia is a largely middle class country, and alleviating poverty and delivering social justice will be not be an easy challenge.

But just like Tunisia showed the way for the rest of the Arab world in January with its unlikely revolution, it now again offers a symbol of hope. Egypt, whose transition is currently a mess, and Libya, where it is only beginning, should take note.