For most in Brazil, what happened in the Rasunda Stadium in 1958 was a gleeful affirmation of what they had always known. They were the world's great football nation and beating the hosts, Sweden, in the final was vindication after the trauma of the defeat to Uruguay in the Maracanã eight years earlier. In an asylum in Barbacena in the state of Minas Gerais, patients clustered anxiously round a radio as the game entered the final minute. A cross came over, Pelé rose and made it 5-2: the world title was confirmed. Patients and staff celebrated together – all except one. In his room, alone, Heleno de Freitas filled his mouth with cigarettes, lit them all and tried to smoke himself to death.

A decade earlier, Heleno had been Brazil's greatest forward. He had dreamed of playing in a World Cup, of winning it for Brazil. What Pelé did at 17, he had yearned for and had the talent to achieve. For him, hearing of Pelé's success was too much. He was prevented from committing suicide but from then on his dementia worsened. He ate the newspaper clippings detailing his triumphs, peeling them from the wall where a nurse had lovingly pasted them, and drifted deeper into decline. He died the following year aged just 39.

"Heleno de Freitas was clearly a gypsy," the Uruguayan poet Eduardo Galeano wrote. "He had Rudolph Valentino's face and the temper of a mad dog. On the playing field he sparkled. One night, in a casino, he lost all his money. Another night, who knows where, he lost all his desire to live."

The Brazilian actor Rodrigo Santoro, who played Xerxes in 300 but is probably still best known in Britain as the bloke in the preposterously expensive Baz Luhrmann-directed Chanel advert with Nicole Kidman, had not heard of Heleno when he was approached by the director Jose Henrique Fonseca. "He brought a photograph of Heleno," Santoro said, "and my first impression was very strong. There was something about him that caught the attention, an elegance."

The actor and director had been looking for a project to work on together and Santoro, without seeing a script, knew this was it. The result is a highly unusual football film, shot in black and white with a self-conscious artistry, a languid portrait of a genius seduced into oblivion by his own demons and by the temptations of the Rio de Janeiro of the 40s.

Fonseca and Santoro had Marcos Eduardo Neves's biography Nunca Houve um Homem Como Heleno to use as source material and scoured Rio looking for people who had known Heleno or seen him play. Santoro discovered his 96-year-old grandfather, a Botafogo fan, had watched him. "There was no footage, just pictures," Santoro said. "But it didn't matter whether people hated him or loved him, he left his mark." He found frustration at talent wasted, anger at how badly Heleno had treated people – women particularly – and adoration for the player he had been. "The guy was a myth," Santoro said. "He was lost in time. He'd been the biggest celebrity at the time and the 40s really saw the birth of soccer. It wasn't cool to be a player at the time; soccer didn't have a good reputation. He was wealthy, he was a prince in Rio society and he left it all behind to be a soccer player."

Heleno, as tradition demands, was spotted juggling oranges on the beach and signed by Botafogo at the age of 17. Two years later, he was in the first team, scoring goals, berating team-mates and opponents, creating his legend. He qualified as a lawyer, but by the early 40s he was the clear star of Botafogo. Fans adapted carnival songs to celebrate him and he would respond by dancing samba on the pitch and mimic distributing bananas to the stands. And he scored goals – lots of them.

Galeano describes – with his usual romanticism – a strike against Flamengo in 1947: "Heleno had his back to the net. The ball flew down from above. He trapped it with his chest and whipped around without letting it fall. His body arched, the ball still resting on his chest, he surveyed the scene. Between him and the goal stood a multitude. There were more people in Flamengo's area than in all Brazil. If the ball hit the ground he was lost. So Heleno started walking and calmly crossed the enemy lines with his body curved back and the ball on his chest. No one could knock it off him without committing a foul, and he was in the goal area. When Heleno reached the goalmouth, he straightened up. The ball slid to his feet and he scored."

But by then, the decline had already begun. Heleno was not just a great player, he was an inveterate drinker, gambler and womaniser, a man of great charm and recklessness. He became addicted to ether, soaking a handkerchief in it and sniffing it for a temporary but damaging high. At some point, he contracted syphilis but always refused treatment, terrified as to the potential impact in his playing career.

He went to the 1945 South American championship in Chile and finished as joint top scorer, but Brazil lost out to Argentina by a point. When he returned, he drove a motorbike across the pitch at Botafogo's training ground and, after being asked to speak to his team-mates to stress their unity ahead of the new season, ended up attacking them for not being as good as him. Fans loved him far more than his team-mates did. In a game against Fluminense, he responded to the jeers of the opposing fans by dropping his shorts and waving his testicles at them, before pointing to the scoreboard, which at the time read 1-1, and holding up two fingers. Almost immediately, Teixeirinha put Botafogo ahead; it was Heleno, though, rather than the goalscorer who was chaired from the field.

Botafogo had finished second in the Carioca championship in 1944 and 1945 and they did so again in 1946. That year Brazil, with Heleno up front, came second again in the South American Championship. Heleno became obsessed by two dreams: winning the World Cup, which had twice been postponed because of the second world war, and winning the Carioca championship.

His behaviour became increasingly erratic. Rival fans began to taunt him by chanting "Gilda", comparing him to the beautiful but impossibly temperamental character in the Rita Hayworth film. With four games of the 1947 season remaining, Botafogo trailed Vasco da Gama, who had played a game more, by four points. They met at the São Januário and drew 0-0. Still there was some hope but when Heleno missed a penalty against Fluminese in their next game with the score at 2-2, Botafogo were doomed to a fourth successive runners-up spot.

If the film is accurate, he reacted badly, punching a wall in the dressing-room until his hand was bleeding, refusing his bonus payments, accusing his team-mates of a lack of effort and then smashing a series of lockers. Carlito Rocha, the president of Botafogo, decided the star was the problem and sold Heleno to Boca Juniors. For the club, it was undoubtedly the right decision: they won the league in 1948. For Heleno, it was a disaster.

Without his wife, Ilma (although in the film she is called Silvia) to act as even some kind of check, he spun further out of control in Buenos Aires. He hated the cold of the Argentinian winter, training in an overcoat and, although he enjoyed his social life – even being rumoured to have had an affair with Eva Perón – he never settled. He returned, contrite, to Rio, but Rocha would not take him back.

Heleno joined Vasco, who won the title that season, but for him it was an empty triumph: he had long since been dropped. After being upbraided for his lackadaisical attitude in training, Heleno returned to the stadium with a gun, placed it against the head of the coach, Flavio Costa, and pulled the trigger. Thankfully it was not loaded.

After leaving Vasco, Heleno joined the rebel league in Colombia, playing for the Barranquilla side Atlético Junior. There he met Gabriel García Márquez, at the time a young journalist. "As a football player, Heleno de Freitas could blow hot and cold," he wrote. "But he was more than just a centre-forward. He was a permanent opportunity for others to speak ill of him."

It was in Barranquilla that Heleno discovered that Brazil had failed to secure the draw they needed against Uruguay to win the 1950 World Cup, the tournament that had for years been earmarked as his. Even had he managed a remarkable return to form in Colombia, he would never have been picked; Brazil had appointed Flavio Costa as coach. Would he have made a difference? Santoro believes so. "He'd played with Obdulio Varela [the Uruguay centre-half] in Argentina," he said. "He knew how to beat him." Well, perhaps, but football rarely offers absolute solutions and it is not as though Ademir, who did play at centre-forward and who had kept Heleno out of the team at Vasco, was a poor player.

Still driven by dreams of the Maracana, the vast concrete symbol of the new Brazil and of the might of Brazilian football, Heleno returned to Rio in 1951, signing for América. He spoke of winning titles and made his debut for them in the Maracana. The film shows him confused and disoriented, spinning in the lights as the game goes on around him. It was his final match. Within two years he had been consigned to the asylum.

In some ways, Heleno is not a football film. There is very little actual football in it – which is probably a good thing given the notorious difficulty of shooting the sport realistically – and what there is is impressionistic. There is rain, gleaming floodlights, challenges hissing by and the occasional thwack of ball on net but that is not where the drama of the film lies. Scorelines, on the handful of occasions they are necessary, are passed on via shots of a scoreboard or the next day's newspapers.

In part that was practical but it was also an artistic consideration. "It's very expensive to shoot football scenes," Santoro said, "getting all the extras and the crowds to look like the 1940s but this was a decision the director took right at the start. It's Heleno looking back from the institution and that's why it's so dreamlike." As Santoro readily agrees, Heleno could be about a pianist or a lawyer – professions the real Heleno seems to have considered if a letter to his mother is to be believed; it is a film about talent and one man's struggle to come to terms with the expectations that brings, both from himself and others.

It becomes a tragedy, the prince of Rio, the prince of Brazilian football, becomes the king of an asylum, goading and bullying other patients as he had once tried to dominate his team-mates. "He had an absolute desire for mastery," Santoro said. "He wanted to be bigger than life." In that dream, as in so many others, he was disappointed.

Heleno was released in the USA last week. Plans for a UK release have yet to be finalised. Jonathan Wilson's new book, The Outsider, was published last week and can be bought through the Guardian bookshop. A detailed history of Colombia's rebel league features in the latest issue of The Blizzard, which went on general sale this week.