SÃO PAULO, Brazil — An openly gay federal lawmaker in Brazil who has frequently clashed with the country’s new far-right president said on Thursday that he was giving up his seat because of death threats.

The lawmaker, Jean Wyllys, a fierce advocate for gay rights who was due to be sworn in for a third term in February, said in an interview with the newspaper Folha de S. Paulo that “this environment isn’t safe for me” after the assassination of a political ally last March and violence that followed the election of the president, Jair Bolsonaro, in October.

“For the future of this cause,” Mr. Wyllys said, “I have to stay alive. I don’t want to be a martyr.” He added that he was currently on vacation abroad and did not plan to return to Brazil.

Mr. Wyllys called Mr. Bolsonaro, a former colleague of his in the lower house of Congress, “a president who always vilified me, who always openly insulted me, who was always homophobic with me.”