Legislation that aimed to bar transgender women and girls nationwide from participating in school athletic competitions designated for female athletes failed to advance Monday night in a divided Senate as Democrats stood united against an issue that Republicans leveraged in last year’s elections.

A test vote on the bill failed to gain the 60 votes needed to advance in the chamber as senators stuck to party lines in a 51-45 vote tally.