David Cameron has hailed the first same-sex marriages in England and Wales as sending a "powerful message" about equality in Britain.

The law changed at midnight, with a number of gay couples vying to claim the title of being the first to be married in Britain by trying to time it perfectly so their vows were said just seconds after the clock struck midnight.

The prime minister said the reform was necessary because "when people's love is divided by law, it is that law that needs to change".

Writing in Pink News he said "this weekend is an important moment" because "we will at last have equal marriage in our country".

Cameron, who has faced opposition from some in the Conservative party about his backing for the change, said: "This is something that has been very important to me.

"I have been so lucky to find the most incredible lifelong partner in Sam, and our marriage has been a very special part of the commitment we have made to each other.

"Of course any marriage takes work, requires patience and understanding, give and take - but what it gives back in terms of love, support, stability and happiness is immeasurable.

"The introduction of same-sex civil marriage says something about the sort of country we are.

"It says we are a country that will continue to honour its proud traditions of respect, tolerance and equal worth. It also sends a powerful message to young people growing up who are uncertain about their sexuality.

"It clearly says 'you are equal' whether straight or gay. That is so important in trying to create an environment where people are no longer bullied because of their sexuality - and where they can realise their potential, whether as a great mathematician like Alan Turing, a star of stage and screen like Sir Ian McKellen or a wonderful journalist and presenter like Clare Balding."

The Marriage (Same-Sex Couples) Act came into force in July last year but it was not until 13 March this year when couples were able to register their intention to marry under the Act for the first time.

While whoever says the words "I do" first can claim the title of first gay couple to be wed in the UK, other couples who previously married abroad have already had their unions recognised.

On 13 March, the law in England and Wales changed to recognise same-sex marriages performed overseas.

Sue Wilkinson, 60, and Celia Kitzinger, 57, married in Canada in 2003 and fought for eight years to have their union recognised here.

They took their fight to the High Court in 2006, when a judge refused to make a declaration that their marriage was valid in this country.

But, due to the change in the law, their marriage became legally binding at one minute past midnight on 13 March.

Among the first couples set to take advantage of the legalisation were Peter McGraith and David Cabreza, who said they wanted to wed as soon as the marriage laws changed.

Ahead of their ceremony at Islington town hall McGraith said: "We are thrilled to be getting married. It is a mark of significant social progress in the UK that the legal distinction between gay and straight relationships has been removed.

"Very few countries afford their gay and lesbian citizens equal marriage rights and we believe that this change in law will bring hope and strength to gay men and lesbians in Nigeria, Uganda, Russia, India and elsewhere, who lack basic equality and are being criminalised for their sexual orientation."

Vying for the title of first same-sex couple to marry in Britain were Brighton couple Andrew Wale and Neil Allard, at a ceremony in the city's famous Royal Pavilion.

Meanwhile, broadcaster Sandi Toksvig and her civil partner Debbie Toksvig will renew their vows at a public event at the Royal Festival Hall on the Southbank in London on Saturday morning.

Rainbow flags will be hung all over the country to celebrate the occasion, with one flying at the heart of Westminster.

The flag - adopted as a symbol of the gay community in 1970s' San Francisco - was being flown above the Cabinet Office and Scotland Office.

Scotland has also legislated to allow same-sex marriages, with the first ceremonies expected to take place later this year.

Louis Monaco will wed his partner Aarron Erbas at 10am on Saturday.

The 46-year-old is originally from New Jersey in the US but now lives in Angel, north London with Erbas, 23.

The pair will also tie the knot at Islington town hall. They will then celebrate with a reception at a north London pub where they met a year and a half ago.

"We're very excited, we have family coming from New Jersey and California," said Monaco, a clinical psychologist.

"We're going to the town hall and we'll have a ceremony there and after we'll be going to a pub where we met.

"Aarron is so excited. He proposed to me. Once I told him we were able to get this date he had the invitations and the reception venue picked out by that night.

"We wanted to do it for different reasons. I am older and I didn't think this would happen during my lifetime anywhere in the world. For Aarron, he's younger and he only came out last year. It is historic and we thought: 'Yes, let's do it'."

Islington town hall will also host a wedding on Friday night, with the vows to be exchanged as soon as the clock strikes 12.

Peter McGraith and David Cabreza, who have been together for 17 years, said they wanted to wed as soon as the marriage laws changed.

McGraith said: "We are thrilled to be getting married. It is a mark of significant social progress in the UK that the legal distinction between gay and straight relationships has been removed.

"Very few countries afford their gay and lesbian citizens equal marriage rights and we believe that this change in law will bring hope and strength to gay men and lesbians in Nigeria, Uganda, Russia, India and elsewhere, who lack basic equality and are being criminalised for their sexual orientation."

Vying for the title of first same-sex couple to marry in Britain will be Brighton couple Andrew Wale and Neil Allard. The pair will wed in Brighton's famous Royal Pavilion.

Five same-sex couples will be married in Brighton on the first day that the act comes into force.

Gay rights campaigners have rejoiced at the move saying Saturday will be a "momentous day".

Ruth Hunt, acting chief executive of gay rights charity Stonewall, said: "Saturday is a momentous day for England and Wales, as the first same-sex marriages mark full legal equality for lesbian, gay and bisexual people.

"The first weddings will send a powerful message to every person in Britain and around the world that you can live and love as you choose, regardless of your sexual orientation."

Human rights campaigner Peter Tatchell, who will attend the McGraith-Cabreza wedding, said: "Peter and David are personal friends and long-time gay rights campaigners. I am delighted to be their witness on this historic day.

"Their marriage is a celebration for them and for the whole lesbian, gay, bisexual and transgender community. It marks the end of the ban on same-sex marriage and is another hugely significant milestone in the quest for lesbian and gay equality.

"The legalisation of same-sex marriage ends the last major legal discrimination against gay people in England and Wales. Scotland will follow later this year. Sadly, Northern Ireland remains a bastion of homophobia.

"Same-sex marriage is an unstoppable global trend because love and commitment are universal human traits, regardless of sexual orientation or nationality. No ignorance or prejudice can hold back the triumph of love."

• This article was corrected on Saturday 29 March 2014 because the headline referred to the UK rather than Britain.