Mr. Torres called for Mr. Díaz to apologize and to be removed from the chairmanship of the Committee on For-Hire Vehicles. Mr. Torres gave a speech from the floor of the Council chambers condemning Mr. Díaz, before the committee was dissolved, and talked of how he had thoughts of suicide related to depression and the struggle with his identity as a young man.

Afterward, he and Carlos Menchaca, an openly gay councilman from Brooklyn, hugged.

“To have an elected official attack the quality and dignity of L.G.B.T. people sends a message to young people who are thinking of taking their own life as they struggle with their identity,” Mr. Torres said.

Mr. Díaz said his views on homosexuality are based on his religion, and that voters in the 15th Congressional District, one of the poorest in the country and predominantly Hispanic and black, accept that. Mr. Díaz calls himself a “conservative Democrat” and recently referred to himself as the “opposite” of Representative Alexandria Ocasio-Cortez, the popular democratic socialist.

“My family is full of gays,” he said. “I don't believe in gay marriage but that doesn’t mean I hate people.”

Those are the sort of comments that make this congressional race urgent, according to the Equality PAC, which supports L.G.B.T.Q. candidates running for federal office, and has also endorsed Mr. Torres.

“What makes this race so important is that it’s shaping up to be a contest between Ritchie Torres and Rubén Díaz, someone who has demonized the L.G.B.T.Q. community throughout his career and shown a profound lack of respect,” Representative David Cicilline, a Democrat from Rhode Island and co-chairman of Equality PAC, said in an interview.

The outside attention is already paying dividends. Mr. Torres estimates that he has already raised more than $500,000. In a fund-raising email last week, Mr. Díaz said that he had raised $80,000.