The legislation includes language protecting transgender students and teachers, has been a priority of advocates for gay and lesbian rights but was ignored for nearly a decade in the Senate.