The cost of issuing a third category of passport would be as little as £2m, the court was told. British border controls already recognise non-gender passports issued by other countries without any problem.

The NHS, Gallafent said, accepted that gender identity was not limited to male or female. It defined gender dysphoria as “a condition where a person experiences discomfort or distress because there’s a mismatch between their biological sex and gender identity”.

Up to 1% of the UK population did not identify as either male or female in a 2012 survey carried out by the Equality and Human Rights Commission, the court was told. That equates to 600,000 people.

Elan-Cane first applied for a gender-neutral passport in 1995 and became aware in 2005 that the International Civil Aviation Organization, which issues international standards for machine-readable passports, had three categories: male, female and X for unspecified gender.

Five years later Elan-Cane wrote to the Home Office requesting an X UK passport, which was denied on the grounds that Britain did not issue them.

A number of other countries have been issuing X passports for many years, in Australia’s case since 2003. They are also available in India, Canada, Malaysia and New Zealand among others.

Before the hearing, Elan-Cane, whose partner, David Brogan, also attended, said: “The government position is untenable as well as discriminatory. Theresa May has raised LGBT rights with Commonwealth leaders yet is still trying to suppress legitimate identity in this country.

“As a non-gendered person, the government sees me as a non-person. All I’m looking for is to be treated equally.”

Human Rights Watch has intervened in the case to support Elan-Cane’s application.

In written submissions, James Eadie QC, for the Home Office, said: “[We] do not accept that issuing passports with an X marker could be done without regard to the implications of recognising non-binary status across the government.

“The amendment to legislative policy would incur a huge administrative burden. There would be significant administrative and financial costs to HM Passport Office in allowing an X marker in passports … The number of people likely to be benefited is relatively modest.”