Few undercover reporters have been prepared to sacrifice as much as the Spaniard who goes by the pseudonym of Antonio Salas. Circumcision was just one hurdle in passing himself off as a radical Islamist and infiltrating the shadowy, interconnected world of international terrorism. "It was more painful than I expected. It is pretty delicate for the first few days," Salas now admits, walking daintily around a room at his Madrid publisher's offices. An invite to a hammam bathhouse during his five years undercover had, he said, persuaded him the operation was necessary.

Salas's identity undercover was Mohammed Abdullah, a Spanish- Venezuelan with Palestinian grand-parents. He was convincing enough to be invited on terrorist training courses and to become personal webmaster to the most infamous of international terrorists, Carlos the Jackal. That meant regular telephone conversations with a man thought to be responsible for more than 80 deaths.

The Jackal would call from La Santé prison in Paris, where he is still serving a life sentence for murder. "He was very worried about my security," says Salas. "It is a strange sensation when a self-confessed assassin like Carlos the Jackal does that, and offers their friendship."

Salas decided to go undercover with his hidden cameras after the bombings that killed 191 people on Madrid commuter trains on 11 March 2004. He had been as stunned as other Spaniards by the blasts, despite the country's experience of Basque terrorist group Eta. "I wanted to know what goes through the mind of a person who is capable of killing for an ideology."

Salas's previous undercover investigations – as a skinhead supporter of Real Madrid football club, and in the world of prostitute-trafficking – had taken him to the heart of some of the most violent groups in Spain. "My aim was to understand terrorism in the same way that I came to understand skinheads or prostitute-traffickers."

He learned Arabic and invented an elaborate cover story involving a dead wife: 25-year-old Dalal Mujahad from Jenin, tragically killed by an Israeli bullet while pregnant with their child. The real Dalal, whose name he found in a newspaper archive, had died in 2004, when a bullet entered her house in a shoot-out. In case anyone decided to investigate, he added a Romeo and Juliet touch: the marriage had been kept secret because his (false) mother's family, from the nearby village of Burkin, backed Al-Fatah, while Dalal's family were part of Hamas. Her death, he would claim, had pushed him towards radical terror.

"I took photos of myself in Burkin and in Jenin. Then I asked Fatima, a girl I met when investigating prostitute-trafficking, to let me take photos with her as if she was my wife. We mocked up an apartment in Barcelona to look as though it was in Palestine and took photos." Salas also wrote out the Qur'an by hand, and considers his conversion to Islam to be genuine. He treasures the small booklet in which he wrote Islam's most sacred text: "It helped convince people," he says. "Not many people carry their own, hand-copied version."

The final part of his cover was to become a pro-jihad journalist, contributing to radical publications. He travelled around the Arab world, from Egypt to Jordan and the Lebanon, writing articles that would help to seal his militant credentials. "I even wrote a couple of books," he says. It did not take long to gain a reputation. "I remember the first time I dropped off some newsletters at a mosque in Tenerife, the police arrived with flashing lights and sirens and they soon had me pinned against a wall."

Salas picked the Venezuela of President Hugo Chávez as his base. "I had been told Venezuela was a mecca of international terrorism," he says. "The Farc group from Colombia was there, as were people from Eta." Numerous other small revolutionary groups had also set up under Chávez's benevolent gaze. There, in what the New Yorker journalist Jon Lee Anderson calls "the parallel reality that is the Bolivarian Republic of Venezuela today", Salas established himself as yet another niche radical – flying the flag for Palestine and running a local branch of Hezbollah. More importantly, he got close to the family of Ilich Ramírez Sánchez – Carlos the Jackal.

"I only really knew about Carlos because of the films about him," admits Salas, who is in his mid-30s and too young to recall the The Jackal's bloody kidnaps and assassinations in the 70s and 80s. "But here was an icon of international terrorism. He was Venezuelan, and a convert to Islam who had fought for Palestine. It was perfect for my profile." He sought out The Jackal's two younger brothers, Vladimir and Lenin – names given to them by their Leninist lawyer father. "Vladimir is the more active defender of his brother," he says. "Lenin is a lot more discreet. Later I met his mother, his nephews and got in with the family."

He first spoke with The Jackal by chance, when Carlos rang from prison while Salas was with the family. "We started out talking in Arabic and then in Spanish. I called him Ilich or 'Comandante Salim', which is his Arabic name. He speaks six or seven languages and is very intelligent. We would talk for up to an hour. He would not let me ask questions – they made him angry. So I just let him talk. He even confessed some of his killings, and I have that taped."

Salas began to work on a website that, among other things, campaigned to have The Jackal repatriated to Venezuela. "To prove the website was close to Ilich, I was given access to a trunk that had been closed for 30 or 40 years – with his school reports and family photos. I spent a lot of time in Vladimir's house, classifying the material." Salas would post texts to La Santé; The Jackal sent them back with neat, handwritten corrections. He also sent prison photographs to put on the site.

By tracking the Arabic news channel al-Jazeera, Venezuelan TV and the internet for mentions of The Jackal, Salas discovered that Chávez himself was one of his biggest fans. "For him, Carlos is not a terrorist but a revolutionary – a model internationalist, like Che Guevara. Just as Che went to fight for other peoples, so Ilich went to fight for the Palestinians. Whenever Chávez mentioned The Jackal, I would record it and send it to him, which he loved."

Not that Salas agrees with Chávez's view of The Jackal. "He is considered responsible for 82 killings; I don't call that being a revolutionary. I call him a terrorist." – though he would probably not, he admits, use the term to his face. "It helps that he is in jail."

Salas updated The Jackal's website from cybercafes, using a different one every time. "I imagine Mossad, the CIA and MI6 being driven mad by the fact that The Jackal's page was updated from Portugal one day, Syria another, and from other countries."

Salas was even invited to visit La Santé, but he passed up the offer. As an independent journalist who pays his own way and has no back-up, he must use his real identity when going through frontiers or security controls. "I have never worked for any intelligence service, political party, or even for any one media outlet," says Salas, who produces his own undercover films and publishes books on his investigations. "I only work for my readers. They are the ones who end up paying for my investigations. I work alone, using my own money and passport. Journalistically, it would have been great to meet Ilich, but I couldn't do it."

In Venezuela's fringe community of political extremists, he bumped into people from Eta, the Túpac Amaru (a group of armed Venezuelan radicals who support Chávez), and other groups. Repeated requests for hands-on training eventually saw him invited to a camp in Venezuela, where he learned to handle pistols, rifles and machine guns, including a Kalashnikov AK-103, an Uzi sub-machine gun, the American M4 carbine and a Belgian-designed FN FAL. He also practised with a sniper's telescopic sight and received explosives training. "I learned all that a jihadist might need to take his message of terror to a city in Europe or the United States," Salas says. "There was nothing glamorous about it. It was just a question of learning to kill better."

His instructors included a Venezuelan army colonel, though Salas insists the camp was not run by the Chávez regime. "It just so happened that my instructors, as well as being supporters of revolutionary causes, were Venezuelan army officers."

His strangest discovery was the willingness of different extremist groups to blindly embrace the varied causes of others, even when they had nothing to do with one another. So it was that, as a supposed Palestinian Islamist, he found himself appearing in a video for the Túpac Amaru. Salas stood manfully beside leader Alberto Carías clutching a Heckler & Koch MP5-A3 sub-machine gun, as the latter urged armed revolutionary groups across South America to join forces.

Salas came close to blowing his cover only once, when he met US journalist Jon Lee Anderson, who was in Venezuela promoting his Che Guevara biography. It was a nerve-racking encounter. "When he said he had been to Burkin and started naming people there, I feared my cover was gone."

Anderson remembers the meeting: "Burkin is an amazing place in the hills above Jenin. It is said to have the finest olive oil in the world. I remember thinking there was something odd [about Abdullah]; he was cautious around me and flustered, but Caracas is full of wackos. It didn't occur to me to think he was a plant."

Far from being made world-weary or cynical by his exposure to such violent worlds, Salas remains almost naively optimistic about the results of his investigations – which have spawned Spanish best-sellers, popular documentaries, even a feature film. After his previous two books, he says, he received letters from people who had given up being skinheads or frequenting prostitutes. "I hope for the same thing with this," he says. "In Spain and Latin America there are a lot of adolescents – many of whom I saw arrive at the mosque for the first time as children – who will feel the draw of violence in a few years' time."

So what conclusions does Salas draw from rubbing shoulders with international terror? His answer is coloured by the fact that half a dozen people he met during his investigation have since died – often violently. "I don't justify violence, but I can understand it. I never found any glamour or sophistication in that world, nor anyone especially intelligent – except for The Jackal. Terrorists really have only two ends – they either die or go to jail. You have to be a bit stupid to do that."

• Carlos will be screened at the London Film Festival this Saturday and is in cinemas from October 22