After decades of dictatorship and two years of arguments and compromises, Tunisia's new constitution has come into force.

In a ceremony on Monday in the national assembly, the president, Moncef Marzouki, the outgoing prime minister, Ali Larayedh, and the speaker, Mustapha Ben Jaafar, signed the document while deputies sang the national anthem.

In a statement, the UN secretary general, Ban Ki-moon, said: "Tunisia can be a model to other peoples who are seeking reforms."

The new constitution is considered one of the most progressive in the Arab world, and was passed late on Sunday by 200 votes in the 216-seat assembly in Tunis.

"This constitution, without being perfect, is one of consensus," the assembly speaker Ben Jaafar said after the vote. "We had today a new rendezvous with history to build a democracy founded on rights and equality."

The constitution, which enshrines freedom of religion and women's rights, took two years to finish. During that period, Tunisia has been hit by high unemployment, protests, terrorist attacks and political assassinations. At times politicians seemed more interested in posturing than finishing the charter.

But unlike in Egypt, where in the past two years two constitutions have been quickly drafted by appointed committees with little public debate or input, in Tunisia the elected assembly of Islamists, leftists and liberals worked on a detailed roadmap for their political future.

Tunisians hope that this care in the drafting process will make a difference, and help return stability to the country. It is also likely to reassure investors and allies such as the US.

"We needed time to get this constitution as it is today," said Amira Yahyaoui, who has closely followed the assembly's activities with her monitoring group Bawsala. "Clearly, writing this constitution to do a real transformation of the minds of people needed time and I absolutely don't regret these two years and I am happy we had time to discuss and think about all the arguments."

The new constitution sets out to make the country of 11 million people a democracy, with a civil state whose laws are not based on Islamic law, unlike many other Arab constitutions. An entire chapter, made up of 28 articles, is dedicated to protecting citizens' rights, including protection from torture, the right to due process, and freedom of worship. It guarantees equality for men and women before the law and a commitment from the state to protect women's rights.

"This is the real revolution. Many democratic constitutions don't even have that," said Yahyaoui. "It will have a real impact on the rest of the Arab region, because finally we can say that women's rights are not a western concept only, but also exist in Tunisia."

Tunisia has always had the most progressive legislation on women's rights in the Arab world and Yahyaoui believes the longer drafting process for the new constitution has made people comfortable with its contents.

One of the most debated articles guarantees "freedom of belief and conscience", which would permit atheism and the practice of non-Abrahamic religions frowned upon in other Islamic countries. It also bans incitement to violence and declaring a Muslim an apostate – a fallen Muslim – which leaves them open to death threats. In response, conservative lawmakers insisted "attacks on the sacred" be forbidden, which many see as a threat to freedom of expression.

"This formulation is vague and gives too much leeway to the legislators to trample other rights such as the right to free expression, artistic creation and academic freedoms," said Amna Guelleli, of the charity Human Rights Watch. "However, the risk is reduced given the strong safeguards [in place in other articles] against overly broad interpretations."

Since the revolution in 2011 against the 23-year rule of President Zine al-Abidine Ben Ali, there has been a rise in convictions for so-called attacks on religion, especially by artists. A Tunisian cartoonist is in the second year of a seven-year sentence for posting cartoons insulting the prophet Muhammad on Facebook.

The constitutional scholar Slim Loghmani said that despite some drawbacks, the constitution was a "historic compromise between identity and modernity" that could serve as a model for other countries in the region seeking a balance between an Arab-Islamic heritage and contemporary ideas of human rights and good governance.

"It's a step forward in the nagging question of cultural identity in Arab countries," he said, lauding in particular not just freedom of religion but what he calls the freedom "not to have a religion".