Malta used to be known as a very conservative country, where social opinion, reflected in politics and policies, was heavily influenced by the Roman Catholic Church. Divorce was outlawed, abortion was — and remains — criminalized in all cases, and the law failed to address key human rights concerns affecting lesbian, gay, bisexual, transgender and intersex people.

On one front at least, in the past four years, this country of 420,000 people has pleasantly surprised the world with progressive LGBTI rights legislation. It introduced a gender identity recognition bill, drawing on best practices that place it as a leader ahead of many other countries. Transgender people can have their gender identity reflected in their identity papers without the interference of courts, doctors or psychiatrists. Maltese citizens can choose to have “female” or “male” removed from their passport and identity cards and replace it with an X.

The government also introduced a law banning cosmetic surgery on intersex babies. Reparative conversion therapy for gay and lesbian people was outlawed. And the government adopted civil unions, including for same-sex couples, as well as adoption by same-sex couples.

What is the secret behind Malta’s rapid progress on LGBTI issues? I decided to visit the island and ask around. I met with human rights defenders, Catholic parents of lesbian and gay children, government officials, the archbishop, the prime minister and foreign diplomats. I asked them their take on the recent legal changes.

The Maltese Gay Rights Movement (MGRM), a voluntary organization, has been working to promote equal rights and ban discrimination for a very long time, unseen by the rest of the world. In the beginning, Maltese LGBT activists were considered outcasts, but eventually their message started to resonate with the general society. They were emboldened by Malta’s accession to the European Union in 2004. Malta slowly changed its perspective from an inward-looking island to a country with a broader perspective.

But the real game changer was the 2011 divorce referendum. Despite opposition from some political parties and a vocal Roman Catholic Church, the majority of the voters surprised everyone with their ‘Yes to divorce’ vote. It was the first time that the people distanced themselves from the church and the political elite. Soon people came to realize that legalizing divorce did not lead to disaster, the end of family life, or the Maltese identity, as some had predicted.

In 2013 the Labour Party won the general elections. Prime-minister Joseph Muscat showed the political will to adopt a progressive human rights agenda for LGBTI people that activists were advocating. Even the Roman Catholic Church had learned from the unexpected outcome of the divorce referendum. In 2014 Archbishop Charles Scicluna publicly supported the same-sex civil union legislation, acknowledging that it reinforced the dignity of same-sex couples and their relationships.

When I met with him on June 9 he said the church had treated gays and lesbians badly in the past and that he felt the church should apologize to them. He feels that the church needs to welcome everyone, irrespective of their sexual orientation or gender identity, and support them in their dignity. Although he remains opposed to marriage equality — he regards marriage as a procreative bond between a man and a woman — he said he would not campaign against the marriage equality bill that the government has pledged to introduce.

Prime Minister Muscat invited me to his office. A few days before, he had been re-elected for a new five-year term. The proposed marriage equality bill, he proudly announced, would be the first new bill introduced in parliament under his second government. He expects the bill to pass easily, based on the pledges made by all political parties to support marriage equality during the election campaign — making Malta the 23rd country in the world to embrace marriage equality. He did not want to offer a revision of the ban on abortion.

As Malta continues to grow more outward-looking and forward-thinking, and continues its integration into Europe, the government should view its progressive stance on LGBTI legislation as an example of best practice, learn from it, and extend the inspiring progress on LGBTI issues to other human rights topics, including other sexual and reproductive rights.

BORIS DITTRICH is LGBT advocacy director with Human Rights Watch.