European Union officials urged Ukraine on Wednesday to press ahead with a bill banning discrimination based on sexual orientation, one of several legislative measures tied to its bid to secure visa-free travel to the bloc.

The bill’s backers on Tuesday got only 207 of the 226 votes needed for passage in parliament. Two parties in the governing coalition, as well as the opposition, voted largely against or abstained.

The...