If Kate Middleton has a baby girl in July, she will become third in line to the throne - even if the Duke and Duchess of Cambridge have a son afterwards.
Queen Elizabeth is set to give her royal assent to the bill, which stops male heirs taking precedence over females.
A Cabinet Office spokesman told Sky News that The Succession to the Crown Bill will be sent to the Queen in "the coming days or weeks".
It has received its third reading in the House of Lords, meaning it now only needs royal assent to become law.
The bill says: "In determining the succession to the Crown, the gender of a person born after 28 October 2011 does not give that person, or that person's descendants, precedence over any other person (whenever born)."
It also changes the law regarding the royal's marriage to a Roman Catholic, decreeing that "a person is not disqualified from succeeding to the Crown or from possessing it as a result of marrying a person of the Roman Catholic faith."
Another change included means that any descendant of George II will no longer need to seek permission from the king or queen to marry - only the first six people in line to the throne will need to do this from now on.
Deputy prime minister Nick Clegg, who introduced the bill in the House of Commons, said it was a "truly historic moment".
"I am proud that the British parliament has taken this step to end centuries of religious and gender discrimination," he said.
In January, the Queen declared that if Kate and Prince William have a girl, it will be given the title of princess.
Previously, only the firstborn son of the Prince of Wales would automatically be given a royal title. If the child were female, she would have been given the title of lady.
Published in the London Gazette, the formal announcement said: "The Queen has been pleased by Letters Patent under the Great Seal of the Realm dated 31 December 2012 to declare that all the children of the eldest son of the Prince of Wales should have and enjoy the style, title and attribute of Royal Highness with the titular dignity of Prince or Princess prefixed to their Christian names or with such other titles of honour."
The sex of the Kate and William's baby is not yet known, although the duchess appeared to let slip she was having a girl on a visit to Grimsby in March.