Image copyright iStock Image caption The law in North Carolina requires people to use toilets that match the gender listed on their birth certificate

The University of North Carolina must allow transgender students and staff to use the toilets that match their gender identity, a US judge has ruled.

A state law passed in March requires transgender people to use toilets that correspond to the sex on their birth certificates.

The ruling led to boycotts of the state by some sports teams, businesses, and entertainers.

The full case challenging the bill is expected to go to trial in November.

US District Court Judge Thomas Schroeder said three plaintiffs challenging the measure had a strong chance of proving that the state's toilet-access measure violated federal law, and temporarily blocked the university from applying the state law.

Image copyright Reuters Image caption Joaquin Carcano, right, pictured with fellow plaintiff Angela Gilmore, says the fight is not over

"The individual transgender plaintiffs have clearly shown that they will suffer irreparable harm in the absence of preliminary relief," he wrote, noting their assertions that single-occupant toilets were generally unavailable at the University of North Carolina.

'We just need to pee' transgender protest

Why toilets are a battleground for transgender rights

One of the three people who challenged the law is University of North California student Joaquin Carcano.

"Today, the tightness that I have felt in my chest every day.... has eased. But the fight is not over: we won't rest until this discriminatory law is defeated,'' Mr Carcano said.

Legislators in North Carolina enacted the law after the city of Charlotte passed a bill allowing transgender people to use toilets according to gender identity.

Image copyright AP Image caption The governor said Charlotte's ordinance was a "threat to public safety"

Lawmakers in several other US states have proposed similar legislation - sometimes referred to as "bathroom bills".

Some people have said that allowing transgender people to choose their toilet could lead to women and children being attacked.

They said they feared that predatory men could pose as transgender people and use legal protections as a cover.