In the flurry of blue and white that lit up Rio de Janeiro’s vast Sambadrome last week, black bands could be spotted on some of the wrists of those who marched to the driving beats.

It was an uncharacteristically sombre touch for the prestigious Beija-Flor samba school, 12 times winners of the city’s carnival parade, whose symbol is a gigantic hummingbird. The black bands worn at a rehearsal for the carnival, which begins on Friday, were a tribute to a dancer who had been killed the week before.

Claudio da Silva, 25, a transvestite who lived as a woman and was known by the name Piu to those in the school where she danced, had often joked to the “queen of the drums”, Raissa de Oliveira, that she would one day steal her crown and take her place as the most prominent woman in Beija-Flor’s parade. That ambition was never to be realised as Da Silva’s tortured corpse was discovered on 23 January, a few weeks before the carnival.

It was a murder that provided macabre confirmation of Brazil’s homophobia and transphobia problem, as well as shining a light on the criminal underworld that lurks behind the happy-go-lucky carnival facade.

The alarm had first been raised the week before, when Da Silva failed to turn up for a rehearsal at the samba school’s quadra, or main hall – she never missed a practice, so her relatives and friends became concerned.

Next day a shocking video surfaced on social media, purporting to show her being tortured to death in a nearby favela known as Morro da Mina. Da Silva lived in the neighbouring district of Anchieta, which is close to both the samba school headquarters and Morro da Mina.

The footage showed Da Silva pleading with unseen aggressors while they grilled her about what she was doing there. Her face and body were already covered in blood. Frantic relatives searched the area after the video was released and found her body, disfigured and riddled with bullets. There has since been wild speculation about what caused her tragic death.

The most obvious motive appeared to be transphobia. The world of carnival is defined by its high camp, and in recent years a gay soap actor had appeared on a strawberry-scented float to rapturous applause. Men dressed as women fill the streets of Rio as part of the celebrations.

Yet homophobia is also entrenched in Brazil, with one gay, trans or bisexual person killed on average every 28 hours. Some of the online comments seemed to back this up, condemning the wristband homage and using derogatory homophobic slang such as bicha (animal) to describe Da Silva.

On 29 January, six days after Da Silva’s body was found, a National Trans Visibility day was held in Brazil, with transvestites and transsexuals descending on Rio’s city hall to raise awareness of violence and prejudice against trans people.

Beatriz Cordeiro, 28, from Projeto Damas, which works to get trans people into employment, said: “Foreigners come to carnival expecting free sex and love, but the image Brazil exports of freedom and liberty is false. There is a lot of prejudice in society still.”

Murders of transsexuals and transvestites are common, with 312 trans, gay or bisexual people murdered in 2013, according to a report by Grupo Gay da Bahia, Brazil’s most established gay rights group. There were clues, however, that other motives could also have contributed to Da Silva’s murder – ones related to the organised crime that is pervasive in places like Morro de Mina. One indication was the wall of silence that greeted her death from many quarters.

“People are afraid to talk. You never know who is listening or watching, and they don’t want to get involved,” one member of Beija-Flor said, in reference to the climate of fear surrounding the dancer’s murder.

The samba school would not respond to media requests, and many members refused to even confirm that they knew Da Silva, despite her attendance record and reputation as one of the most lively members of the Beija-Flor school.

“I only knew Piu by sight, as she was in the quadra every Wednesday and Thursday,” one woman told the Extra newspaper. “The story made me sad, so I came to show my support.” Others refused to speak at all.

The tortured body of Claudio da Silva, known as Piu, was found two weeks ago. Photograph: Observer

The area of Nilopolis in Rio’s northern suburbs, far from its beaches and tourist attractions, is not only home to the Beija-Flor school, founded in 1948, with its illustrious place in samba history; it is also covered by a patchwork of favelas dominated by frequently warring drug gangs, including the notorious Comando Vermelho (Red Command), which has control of the Morro da Mina.

On the Facebook community page dedicated to Nilopolis, some residents describe Morro da Mina as a “hell” where violence rules.

In the richer, southern parts of Rio where tourists flock, favelas dominated by drug gangs for decades have been occupied by military police pacification units (UPPs) since 2008. The project has claimed some success in reducing murders, but violent and corrupt police methods have been criticised.

One of the limitations of the project has been its restriction to certain areas, leaving others in the north and east of the city all but abandoned by state forces.

“The UPP was seeking to permanently engage excluded places, but every community is different, and it is not clear why the authorities decided to only install 40 UPPs,” said Robert Muggah of the Rio-based security thinktank Igarapé Institute.

As well as traditional armed groups selling drugs, militias made up of police and ex-police and other forces have taken control of much of the territory in recent years. Operating as a kind of mafia, the militia gangs sell services such as gas to the community at inflated prices, and extract money through extortion and protection rackets. They also mete out their own crude form of social justice: beating up gay men and punishing women who have cheated on their husbands.

Da Silva’s explanation to her torturers in the video – that she was meeting a policeman – has led to speculation that she was somehow connected to the gangs, perhaps acting as an informer, although her family has denied this. “We’re perplexed. She wasn’t involved with a militia. Her business really was samba,” said her brother-in-law, Luiz Henrique Guimaraes.

Rio’s Civil Police declined to comment on the case, only stating that investigations are continuing.

Despite attempts to clean up the samba world, it is still heavily funded by criminal activity, including drug gangs and gambling moguls. Beija-Flor has been under fire in recent years for being funded and controlled by bicheiros, the bosses of an illegal but profitable gambling game called Jogo do Bicho, or the Animal Game.

Rio’s mayor Eduardo Paes even admitted he was powerless to eliminate the power of criminal gangs over Rio’s samba schools in the face of the huge popularity of their performances, particularly at carnival time. “Annoying? Yes, it is. But am I going to end carnival?” he said.

More than 900,000 tourists are expected in Rio for the official parade on Friday. The Beija-Flor school has planned a sumptuous parade, with the theme of Equatorial Guinea, in a nod to the African roots of both the samba sound and the people living in the poorer communities where it thrives.

The school’s leaders refused to say whether the show would include a tribute to its much-loved dancer Piu.

• This article was amended on Sunday 8 February 2015 to correct the spelling of bicha. In the original, we had it as bicho. This has been corrected.