There are two main relevant laws - the Gender Recognition Act 2004 and the Equality Act 2010.
The GRA is the law that allows a person to change their legal sex.
www.legislation.gov.uk/ukpga/2004/7/contents
Applicants need to 'live as' their chosen gender for 2 years (in practice this means things like changing name and sex on drivers licence, passport, household bills etc.). They also need two medical reports - one of which must include the diagnosis of gender dysphoria, the other must include details of any treatment (hormones, surgery). It is not a requirement to actually have any treatment, however if an applicant has not had genital surgery they must give a reason in their application. Any reason will do, including 'I don't feel it's right for me.'
The application forms and guidance docs on gov.uk are very useful for more info on exactly what's required:
www.gov.uk/government/publications/gender-recognition-certificates-t455
www.gov.uk/apply-gender-recognition-certificate/how-to-apply
There are a number of exceptions in the GRA where someone who has changed their legal sex will still be treated as their birth sex, for example hereditary peerages, parenthood and sports (where necessary for fair competition or safety). The GRA also allows for exceptions to be made in other legislation.
Section 22 makes it a criminal offence for someone to disclose the trans status of someone with a GRC, or who is applying for one, if that information was gained in an official capacity. There are a number of very tight exceptions, none of which relate to the safety or wellbeing of women or the protection of single sex spaces or services.
A couple of years ago there was a consultation in England and Wales on reforming the GRA to permit self-ID (just signing a piece of paper). The government decided not to make any changes in the end except to reduce the application fee from £140 to £5 and to work towards allowing people to apply online. GRA reform is a devolved matter and there was also a consultation in Scotland - I'm not sure where that one is up to (Scotland is a whole other can of worms in terms of legislation and activism!)
www.gov.uk/government/consultations/reform-of-the-gender-recognition-act-2004
The Equality Act protects everybody from discrimination based on 9 separate protected characteristics. The two most relevant are sex and gender reassignment, although the pcs of sexual orientation and religion or belief are also relevant.
www.legislation.gov.uk/ukpga/2010/15/contents
Sex is defined as a man or a woman and a woman is defined as a female of any age.
Gender reassignment has a very wooly definition that boils down to anybody who says they are trans has the pc.
The EA permits single sex spaces and services where this is a proportionate means of achieving a legitimate aim, and also permits the exclusion of tw from women only spaces/services, even if they have a GRC.
The way the two laws interact is not 100% clear and there is some disagreement, also about how the EA should be interpreted. This page is a good summary of what the law says:
fairplayforwomen.com/legal-basics/
There was a recent inquiry into enforcing the equality act and the role of EHRC (equality and human rights commission). One of the recommendations was that in the absence of case law, EHRC should write a new statutory code of practice on the single sex exceptions and how they apply to people with the pc of gender reassignment. EHRC said they couldn't do that because there was no case law.
old.parliament.uk/business/committees/committees-a-z/commons-select/women-and-equalities-committee/inquiries/parliament-2017/enforcing-the-equality-act-17-19/publications/
So changes to the way the law is interpreted, or even just some clarity, will need to come from individuals bringing discrimination cases. A good way to stay up to date with those is to keep an eye on this forum, there's usually a thread or several on upcoming cases and recent judgments.