WARSAW, Poland — A few years ago, Robert Wegrzyn's off-color joke about gays and lesbians would just have gotten a grin. Now it might cost the Polish member of parliament his job. The shift is a sign of changing mores in what is still arguably one of the European Union's most anti-gay countries.

In an aside to a TV reporter during a parliamentary debate recently about whether to allow civil partnerships, Wegrzyn said: “We can forget about gay men, but I would gladly watch lesbians.”

A media storm erupted, and a befuddled Wegrzyn quickly tried to make amends by issuing an abject apology. “I am very sorry that my joke … was not taken as only a joke. I am sorry if anyone was offended, because it could have been taken as sexist, which really was not my intention,” he said, before going on to say that he was still adamantly opposed to allowing civil unions for gay couples.

His apologies did not mollify the authorities of the ruling Civic Platform party, with Tomasz Tomczykiewicz, the party's parliamentary leader, calling his comment “stupid,” while local officials will decide whether to throw Wegrzyn out of the party.

The difficulties of Wegrzyn, 42, are a sign of the changes that are sweeping through Poland, in large measure as a result of the country joining the European Union in 2004. Overwhelmingly Roman Catholic and socially conservative, Poland had little place for issues like gay rights — even though, unlike in many U.S. states and European countries, homosexuality has been legal here since 1932.

Until recently, opposing any expansion of gay rights was a political winner. Lech Kaczynski, the Polish president killed in last year's air disaster, twice banned a gay pride parade from Warsaw's streets in 2004 and 2005 when he was the Polish capital's mayor — a stance that endeared him to his hard-right electorate in the 2005 presidential elections.

Opinion polls show that Poland is still far from accepting gay rights, with about three-quarters of Poles opposed to gay marriage, an overwhelming majority against the adoption of children by homosexuals, and Poles evenly divided on whether gays should be allowed to have sex.

But the fears of conservative Poles, who warned that joining the EU would steadily change the country, have been borne out.

There is still little political traction in being pro-gay. The centrist Civic Platform party wants as little to do with the issue as possible, while even the ex-Communist Democratic Left Alliance is leery of appearing too pro-gay, as ex-prime minister Leszek Miller admits, because of the socially conservative nature of otherwise left-wing voters.

But socially, being openly anti-gay is becoming as unacceptable as being anti-Semitic: A decade ago it was possible to hear otherwise cultured and intelligent Poles declaiming on how Jews controlled both capitalism and communism, but outside of marginal groups like soccer hooligans, such views are now almost never publicly expressed.

The quickly changing standards haven't just caught up to Wegrzyn. A couple of years ago the center-right Rzeczpospolita newspaper ran an editorial cartoon showing two men getting married. In the foreground a man tells a goat: “As soon as those two gentleman are married, it will be our turn.” The outcry was immediate and intense, and the paper and its editors are being sued over the cartoon.

Although gay marriage is still a long way off — there was recently a flurry in parliament over a law harmonizing Polish regulations with European ones, which some right-wingers worried would allow gay people who had been married elsewhere in Europe to have their marriages recognized in Poland — Polish courts have already recognized that gay couples living together have acquired similar rights to co-habitating heterosexual couples.

The price of being rabidly anti-homosexual is also rising.

Ryszard Legutko, a member of the European Parliament for the right-wing Law and Justice party was recently proposed as a possible leader of the European Conservatives and Reformists, a eurosceptic faction where Britain's conservatives rub shoulders with various central European nationalists. But Legutko's candidacy went up in flames after running into a storm of protest from Britain, where Prime Minister David Cameron has been very inclusive of gays, because of Legutko's comments that “tolerance” is a word that should be struck from the dictionary and denouncing the “horrendous” demands of homosexuals.

That is a lesson that Wegrzyn is painfully learning right now. Even if he manages to not get thrown out of the party, his chances of running for parliament in this fall's election are remote. Donald Tusk, Poland's prime minister, personally reviewed the names of people running for parliament and crossed off those “who bring shame to Civic Platform,” say party insiders.

Wegrzyn is mentioned as one of the most likely candidates for demotion.