All Commonwealth realms have agreed to press ahead with a bill ending discrimination against women in the succession to the British throne.
Deputy Prime Minister Nick Clegg said the government would now introduce the Succession to the Crown Bill in the House of Commons as soon as possible.
It means the first child of the Duke and Duchess of Cambridge will become monarch, whether a boy or a girl.
The duchess, whose pregnancy was announced on Monday, is in hospital.
She is spending her second day being treated for acute morning sickness in the private King Edward VII Hospital in central London.
The new legislation will end the principle of male primogeniture, meaning male heirs will no longer take precedence over women in line to the throne.
It will also end the ban on anyone in the line of succession marrying a Roman Catholic.
The legislation was agreed in principle at the Commonwealth heads of government meeting in Perth, Australia in October 2011.
Since then, the government of New Zealand has been gathering formal letters of consent from the 15 realms of the Commonwealth.
They have confirmed they will be able to take the necessary measures in their own countries before the UK legislation comes into effect.
In a statement, Mr Clegg described the agreement as an "historic moment for our country and our monarchy".
He added: "People across the realms of the Commonwealth will be celebrating the news that the Duke and Duchess of Cambridge are expecting their first child.
"We can also all celebrate that whether the baby is a boy or a girl, they will have an equal claim to the throne.
"The government will soon introduce the Succession to the Crown Bill which will make our old-fashioned rules fit for the 21st Century.
"It will write down in law what we agreed back in 2011 - that if the Duke and Duchess Cambridge have a baby girl, she can one day be our Queen even if she later has younger brothers."