She said she was often beaten by her father, a distillery worker, who turned her over to the police when she was 16 — in the vain hope, she says, that jail might change her gender expression. She spent two years in jail on charges that she described as “social dangerousness” and then started a new life in Caibarién, where she lived as a woman.

“She landed like a bomb in this fishing town full of macho men,” said Pedro Manuel González, a local writer. “It was a complete scandal.”

Ms. Hernández’s honesty and boldness won over her neighbors, though, Mr. González and other residents said. She got a job cleaning hospital floors and, later, trained as a nurse. An avowed communist, she even became head of her block’s Committee for the Defense of the Revolution — the associations that, among other things, police residents’ political loyalties.

These days, Ms. Hernández juggles her work as an electrocardiogram technician and her occasional cabaret appearances as a drag queen with the needs of her neighborhood of cinder block houses and open sewers. So far, she has persuaded the authorities to install running water at the local clinic, which used buckets for six years; secured some lights for the main street; and got the ration store to order extra milk for children.

While these were local concerns, Ms. Hernandez instantly became a national symbol for Cuban activists promoting broader rights for L.G.B.T. people.

Ms. Castro, director of the National Center for Sex Education, sent a representative in November to see Ms. Hernández and bring her information about gender-reassignment surgery, which, since 2008, has been available free in Cuba’s public health system. Ms. Hernández, who has grown breasts thanks to female hormones, is considering surgery; until she has it, she is legally considered male.

“HER election proves that Cubans can overcome their prejudices when it comes to voting for someone,” Ms. Castro said in an interview. Ms. Castro, who was elected to the National Assembly in February (in a process critics dismiss as artificial because only one candidate appears on the ballot for each seat) is lobbying the legislature for the legalization of same-sex unions.