LONDON — British lawmakers have passed a bill legalizing same-sex marriage in England and Wales, with the first gay weddings expected to take place by next summer.

In what was largely seen as a formality, members of the House of Commons on Tuesday approved minor amendments made to the legislation, which had cleared the House of Lords a day earlier.

Now, all the bill needs is official assent from Queen Elizabeth II, which is expected to come later in the week.

The bill will enable gay couples to get married in both civil and religious ceremonies in England and Wales. It also will allow couples who had previously entered into a civil partnership to convert their relationship to a marriage.