It had all the hallmarks of a traditional British wedding with a three-tier cake, bagpipes, a garden party and even “Keep Calm and Marry On” orders of service, but the Beijing wedding ceremony of a senior British diplomat to his male partner has sparked a fierce debate over gay rights in China.

On Saturday Brian Davidson, 50, the British consul-general to Shanghai, married his American partner in a ceremony held in the garden of the official residence of Britain's ambassador to China.

The Beijing garden is British sovereign territory, and the wedding of Mr Davidson to Scott Chang, 33, is legally binding following the introduction in June of new rules allowing UK nationals in same-sex relationships to marry at British consulates in 24 countries around the world.

The ceremony was a private affair, but Britain's ambassador Sir Sebastian Wood posted on the Chinese social media website Weibo that he was “delighted and honoured to have officiated the same-sex wedding of the UK’s consul-general in Shanghai, Brian Davidson, and his partner at my residence today. We wish them a lifetime of happiness together.”

The ambassador joined dozens of other posting images of the bow-tie-wearing couple; with Mr Davidson posting a wedding snap with the message “Love is Great”. The post was quickly shared online more than 60,000 times and sparked a fierce debate on whether China should legalise gay marriage.

While not illegal, same-sex relations are still a taboo to many in China, where electroshock therapy is still offered as a “cure” to homosexuality at some clinics. Many gay couples complain of official discrimination and same-sex unions are not allowed.

Speaking by telephone from China, Mr Davidson told The Independent that the wedding was a private event and that the couple were “surprised” at the online attention it has been given.

He said: “Obviously Scott and I are very happy to have this opportunity to marry under British law. We are very proud that the UK is one of the few countries in the world to make this happen.”

He added: “It speaks to our principles of equality in the UK. Most of our Chinese friends have said happy they were to see us standing up to say we love each other."

However many Chinese commentators took to Weibo and other social media websites to attack the couple. One said, “That country [Britain] is sick. It’s like the last days of Rome”. Another said that same-sex marriage is “not Chinese culture”, while others made reference to “mental illness” in their posts or suggested the couple would have children with “personality issues”.

However the majority of the posts online were positive and praised the couple, who met eight years ago, reflecting the fact that China’s younger tech-savvy citizens are increasingly accepting of same-sex relations. Over the weekend an online poll for Weibo following the ceremony found just 8,000 people opposed to same-sex marriage, while more than 89,000 supported it.

The Chinese embassy in London did not respond to calls from The Independent, while Chinese state media only commented that Mr Chang’s father had said his son’s choice "ran counter to his own traditions".

However wedding guest Wei Jiangang, the founder of Beijing gay rights Queer Comrades, said Mr Chang’s father “blessed” the wedding.

He told The Telegraph: “Although it was not legal under Chinese law, it still sends a very good and positive message to China's gay community. What moved me the most was their families' blessing, especially the speech given by Scott Chang's father. He said the marriage goes against his tradition, but that his son was a good son and as long as he is happy, he was willing to bless the union.“

A Foreign and Commonwealth Office spokesperson said: "This is a private matter, and we wish the couple every future happiness."