CARACAS (Reuters) - In December 2007, Venezuela’s Hugo Chavez suffered his first defeat at the polls.

FILE PHOTO: Venezuelan President Hugo Chavez (R) talks with Cuban President Fidel Castro at the port of Pampatar on Margarita Island, Venezuela December 11, 2001. REUTERS/Jose Miguel Gomez/File Photo

Although still wildly popular among the working class that had propelled him to power nearly a decade earlier, voters rejected a referendum that would have enabled him to run for re-election repeatedly.

Stung, Chavez turned to a close confidant, according to three former advisors: Fidel Castro. The aging Cuban leader had mentored Chavez years before the Venezuelan became president, when he was still best known for leading a failed coup.

Now, deepening economic ties were making Cuba ever more reliant on oil-rich Venezuela, and Castro was eager to help Chavez stay in power, these advisors say. Castro’s advice: Ensure absolute control of the military.

Easier said than done.

Venezuela’s military had a history of uprisings, sometimes leading to coups of the sort that Chavez, when a lieutenant colonel in the army, had staged in 1992. A decade later, rivals waged a short-lived putsch against Chavez himself.

But if Chavez took the right steps, the Cuban instructed, he could hang on as long as Castro himself had, the advisors recalled. Cuba’s military, with Castro’s brother at the helm, controlled everything from security to key sectors of the economy.

Within months, the countries drew up two agreements, recently reviewed by Reuters, that gave Cuba deep access to Venezuela’s military - and wide latitude to spy on it and revamp it.

The agreements, specifics of which are reported here for the first time, led to the imposing of strict surveillance of Venezuelan troops through a Venezuelan intelligence service now known as the Directorate General of Military Counterintelligence, or DGCIM.

Under Cuban military advisors, Venezuela refashioned the intelligence unit into a service that spies on its own armed forces, instilling fear and paranoia and quashing dissent.

Now known for its repressive tactics, the DGCIM is accused by soldiers, opposition lawmakers, human rights groups and many foreign governments of abuses including torture and the recent death of a detained Navy captain.

According to the documents reviewed by Reuters, the agreements, signed in May 2008, allowed Cuba’s armed forces to:

• Train soldiers in Venezuela

• Review and restructure parts of the Venezuelan military

• Train Venezuelan intelligence agents in Havana

• And change the intelligence service’s mission from spying on foreign rivals to surveilling the country’s own soldiers, officers, and even senior commanders.

The first agreement, according to the documents, would prepare Venezuelan intelligence agents to “discover and confront the subversive work of the enemy.” The second agreement authorized Cuban officials to oversee the “assimilation” and “modernization” of Venezuela’s military.

The presence of Cuban officials within Venezuela’s military has been known for years. President Nicolas Maduro, Chavez’s disciple and increasingly beleaguered successor, said in a 2017 speech: “We are grateful to Cuba’s revolutionary armed forces. We salute them and will always welcome them.”

But neither country has ever acknowledged details of the agreements or the extent of Cuba’s involvement.

In March, after U.S. Vice President Mike Pence denounced Havana’s “malign influence” on Caracas, Cuban Foreign Minister Bruno Rodriguez downplayed the relationship. “I strongly reject repeated and false accusations,” he tweeted, “of Cuban military ‘training,’ ‘controlling’ or ‘intimidating’ in Venezuela.”

Neither Venezuela’s Defense Ministry nor its Information Ministry, responsible for government communications including those of Maduro, responded to emails and phone calls for this article. Cuban officials didn’t respond to requests from Reuters for comment.

Eleven years after they were forged, the military agreements have proven crucial for Maduro’s survival as president, according to security experts, people familiar with the administration and opposition politicians.

With Cuba’s help and training, the military has stood by Maduro and helped him weather an economic meltdown, widespread hunger and crime, and the emigration of more than 4 million people – more than 10 percent of Venezuela’s population in recent years.

In June, Reuters explained how a reshuffling of the armed forces, and proliferation of senior officers, has kept military leadership beholden to Maduro.

Now, the documents laying out Venezuela’s agreements with Cuba – and interviews with dozens of current and former members of the armed services, government officials and people familiar with the relationship between Caracas and Havana – show how instrumental Castro’s help has been as well.

The transformation of the DGCIM, these people say, has been particularly effective. “The most important mission for the intelligence service once was to neutralise any threat to democracy,” said Raul Salazar, a former defence minister under Chavez who opposes Maduro. “Now, with Cuba in charge, the government uses it to stay in power.”

Once Cuba began training DGCIM personnel, the intelligence service embedded agents, often dressed in black fatigues, within barracks. There, they would compile dossiers on perceived troublemakers and report any signs of disloyalty, according to more than 20 former Venezuelan military and intelligence officials.

The DGCIM also began tapping the phones of officers, including senior military commanders, to listen for conspiracies.

The crackdown has led to hundreds of arrests. At least 200 military officials are currently detained, according to the opposition-led National Assembly. Citizen Control, a Venezuelan organisation that studies the armed forces, says the number is over 300.

In a June 2017 report, reviewed by Reuters, the DGCIM accused a soldier, who enrolled in a university considered to be aligned with the opposition, of “ideological and political subversion.” Speaking out for the first time, the former lieutenant recounted how he was handcuffed to a chair in a continuously lit room and beaten until two vertebrae broke.

“Those days had no end,” he recalled. He revealed his story to Reuters on the condition that the news agency use only his first name, Daniel, and not disclose his age.

Since its remaking, the DGCIM’s ranks have swelled – from a few hundred agents early in the Chavez administration to at least 1,500 now, according to former military officials.

A recent United Nations report accused the DGCIM of torture – including electric shocks, suffocation, waterboarding, sexual violence, and water and food deprivation. Under Maduro, DGCIM officers have been promoted to senior positions, including the command of his personal security detail.

Slideshow ( 4 images )

The repression, opposition leaders say, has cowed the armed forces. Juan Guaido, head of the National Assembly, early this year denounced Maduro’s 2018 re-election as a sham and declared, with the support of most Western democracies, that he was Venezuela’s rightful leader.

But opposition pleas for a military rebellion have gone unheeded. “We have failed,” said a senior opposition official involved in attempts to broker talks with military leaders. “We have nothing to offer to convince them.”

“A BASTION OF LATIN AMERICAN DIGNITY”

For Chavez, the changes foreseen by the two agreements resonated on a personal level.

Castro, whom he had long admired, was the first international leader to embrace Chavez as a rising politician in the 1990s.

Venezuela’s military intelligence unit, meanwhile, was run by officers allied with the conservative elite and opposed to Chavez’s vision of transforming a country which, despite boasting the world’s biggest oil reserves, suffered rampant poverty.

When Chavez’s 1992 coup failed, officers from the unit, then known as the Directorate of Military Intelligence, or DIM, were the ones tasked with arresting him. They initially jailed him in one of the same underground cells at the DIM’s Caracas headquarters where Chavez would later detain some of his own political opponents, according to several former officials.

Months after his release from prison because of a presidential pardon, Chavez in 1994 flew to Havana, where Castro, in their first in-person meeting, greeted him at the airport.

In Chavez, Castro saw a like-minded leftist leader of the sort that had become rare since the end of the Cold War. In Venezuela’s vast oil wealth, Castro saw potential nourishment for a Cuban economy starved by the collapse of its former sponsor, the Soviet Union.

With Castro looking on, Chavez in a speech at the University of Havana called Cuba, then in its fourth decade of authoritarian rule, “a bastion of Latin American dignity.” He vowed to cure the capitalist “gangrene” afflicting Venezuela.

After the visit, the two men began to speak regularly, former advisors said.

By the late 1990s, high inflation, low economic growth and increased poverty made Chavez’s Socialist message attractive to a growing number of Venezuelans. In 1998, he was elected president. Almost immediately, he deepened formal links with Cuba.

In October 2000, Castro travelled to Caracas to sign a series of economic agreements. Venezuela would give Cuba enough oil to meet half its energy needs.

Since then, Venezuela has sent at least 55,000 barrels per day to the island, or more than $21 billion worth of oil, according to government figures and average prices over the period. In exchange, Cuba sent thousands of doctors, teachers and agricultural specialists to help diversify Venezuela’s grass-roots economy.

By 2002, many of Venezuela’s elite had tired of Chavez. That April, conservative opposition leaders teamed up with military chieftains, including senior DIM officials, and detained him. But the coup, after a massive popular uprising on his behalf, failed within two days.

Back in power, and with Castro’s blessing, Chavez placed Cuban advisors within his inner circle to tighten security, according to his former advisors and several former military officials. He began a purge of the intelligence service and other top ranks of the military.

He appointed Hugo Carvajal, a lieutenant colonel who had joined Chavez’s 1992 coup effort and later headed the DIM’s investigations division, to be its subdirector. Within two years, Carvajal became its director general.

Carvajal began modernizing the DIM. In an email to Reuters, Carvajal said Venezuela’s central bank provided millions of U.S. dollars in cash to the DIM for new technology, including surveillance equipment and a database to centralize intelligence.

The intelligence boss would lead the service for nearly a decade. Now out of office, he has been sanctioned by the United States Treasury Department for allegedly helping Colombian guerrillas. Last April he was arrested in Spain and remains detained in response to a U.S. warrant for alleged drug trafficking.

In the email, sent through his lawyer in Spain, Carvajal denied the accusations.

In July 2007, Chavez named Gustavo Rangel, a loyalist who headed the army reserves, as defence minister.

At his swearing-in, Rangel spoke of the need for “new Venezuelan military thinking” to counter the “real enemy.” The “empire,” he said, using common Caracas shorthand for the United States, was sponsoring “subversive groups” bent on destroying the revolution.

Reuters was unable to reach Rangel, now retired, for comment.

That December, Chavez lost the referendum on term limits. On television, he vowed a “new offensive” to pursue the goal.

Defense talks with Cuba began. At a meeting in Caracas on May 26, 2008, Rangel and General Alvaro Lopez, Cuba’s vice minister of defence, signed the two agreements.

Under the first agreement, Cuba’s defence ministry would oversee a restructuring of the DIM and advise on creating “new units” inside the service. The DIM would also send groups of as many as 40 officers to Havana for up to three months of espionage training.

According to the documents, Venezuela would send resumes of training candidates for Cuba to vet. Courses included how to handle “secret collaborators,” how to conduct criminal investigations and how to select new intelligence agents.

Most of the training, according to the documents, took place at the Comandante Arides Estevez Sanchez Military Academy in western Havana. At the academy, a cluster of white four-story buildings and parade grounds, Cuban instructors told DIM agents their mission henceforth would be to infiltrate and control the military, according to five people familiar with the courses.

The second agreement created a committee known as the Coordination and Liaison Group of the Republic of Cuba, or GRUCE. The GRUCE, comprising eight Cuban “military experts,” would send Cuban advisors to Venezuela to inspect military units and train soldiers.

One former Venezuelan intelligence official recalled training he received by Cuban instructors on a farm in the eastern Venezuelan state of Anzoategui. Instructors, he told Reuters, drilled students with questions about their political beliefs. The DIM, they said, must be the “tip of the spear” in the fight against “traitors.”

Chavez, fortified by increases in government spending that boosted his popularity, won a new referendum to end term limits.

In 2011, he changed the DIM’s name to include the term “counterintelligence,” reflecting its mission to thwart sabotage from within. By then, the new DGCIM was several hundred agents stronger, former officials said.

Fresh from Cuban training, the new agents began infiltrating barracks. “We lived and trained with the troops to monitor them, keeping the bosses informed,” another former DGCIM officer told Reuters. “We had an iron grip.”

Some agents pretended to be regular soldiers. Others donned their DGCIM uniforms and regularly encouraged soldiers to report on each other. They came to be known as “the men in black,” according to several former soldiers.

“I’ll hand you to the DGCIM,” a battalion commander warned would-be rebels, one soldier recalled. Stories of detentions and torture by DGCIM agents, sometimes wearing skeleton masks and balaclavas, spread through the ranks.

“YOU CAN’T FIGHT THE STATE”

Chavez, following four surgeries in Cuba, died in 2013. Castro in a newspaper column called him “the best friend the Cuban people had in their history.” Voters elected Maduro to succeeded him.

In 2014, oil prices plummeted.

Maduro’s effort to spur the economy failed.

Hunger and shortages hit even the armed forces. A military doctor told Reuters recently that many enlisted soldiers are underweight, subsisting primarily on pasta and lentils.

As growing numbers of troops sought to desert, the DGCIM grew more aggressive. It expanded surveillance, wiretapping senior officers.

On the top floor of its headquarters, some 40 agents in its Operational Communications Division used a platform called Genesi, according to a former member of the team.

The system, designed by Italian telecommunications firm IPS SpA, allows users to “intercept, monitor and analyse every kind of information source,” according to the company’s web site.

IPS didn’t respond to calls, emails or a letter seeking comment at its Rome headquarters. Reuters couldn’t identify an IPS office or personnel working in Venezuela.

In July 2017, Daniel, the Army lieutenant in Caracas, was summoned to his battalion commander’s office. Once a Chavez supporter, Daniel had joined the army in 2004 but under Maduro lost enthusiasm and told superiors he planned to leave. He had enrolled in law classes at a local university while still in the military and taken part in some opposition marches.

Daniel’s behaviour, according to the intelligence report reviewed by Reuters, was “counter-revolutionary.” The report described the university, whose name Daniel asked Reuters not to disclose, as a school for the opposition.

Upon reporting to the commander’s office, Daniel said, three uniformed counterintelligence agents confiscated his phone and said he was needed for an “interview” at DGCIM headquarters.

Daniel said agents transferred him to an underground cell and handcuffed him to a chair. Each day, a man entered and punched him repeatedly. The beatings broke two vertebrae, according to a physician’s report reviewed by Reuters. The cell was lit all hours, causing Daniel to lose track of time.

After 20 days, a military court charged him with treason, rebellion and violating military decorum. Pending a trial, he was transferred to another prison. Six months later, after entering a guilty plea, the court released Daniel on condition he remain in the country. He was expelled from the Army.

Daniel returned to law classes, but regrets pleading guilty. “I’m not sure it was the right thing to do,” he said, but noted that many who don’t enter a plea remain detained indefinitely. “You can’t fight the state.”

The surveillance has hurt even senior officers.

One case sparked national outrage, forcing the government to recognise DGCIM abuse. Rafael Acosta, a 50-year-old Navy captain, died in DGCIM custody on June 29, eight days after agents arrested him.

Tarek Saab, Venezuela’s chief prosecutor, said Acosta was detained for participating in an unspecified “right wing” plot. Acosta’s wife, Waleswka Perez, said the accusations were untrue and accused the DGCIM of torture.

On July 1, Saab said the government had charged two DGCIM agents with homicide. He gave neither a cause of death nor the circumstances in which it occurred. The charges, Saab said in a statement, followed an “impartial” investigation into the “unfortunate event.”

Most DGCIM handiwork never comes to light.

In March 2018, five DGCIM agents summoned Lieutenant Colonel Igbert Marin, commander of the 302nd mechanized Army brigade, in Caracas. Marin, now 40 and the father of two young children, for most of his career was a rising star who had excelled at Venezuela’s top military academy.

His wife, Yoselyn Carrizales, told Reuters the agents took Marin to the Defense Ministry, where he was met by officials including Defense Minister Vladimir Padrino and Ivan Hernandez, the current head of the DGCIM.

The officials accused Marin of scheming against the government, said Carrizales, who is acting as one of Marin’s attorneys. They said they had video evidence of Marin and eight other officers conspiring, she added, but didn’t show him the video.

Marin denied the allegation, saying that the meeting in question had been merely a gathering of old academy classmates. Indignant, he told the defence minister that such accusations were counterproductive, especially at a time when most of the military was suffering from shortages of food, pay and equipment.

The minister should “leave his office, open his eyes and see how soldiers actually feel,” Marin told Padrino, according to Carrizales. Another lawyer defending Marin, Alonso Medina Roa, confirmed her account.

Neither Padrino nor Hernandez could be reached for comment.

The agents took Marin and the eight other officers to DGCIM headquarters. Marin later told his attorneys that agents handcuffed him to a chair, placed a bag over his head and filled it with tear gas. His lawyers detailed the alleged abuse to Reuters.

A week later, at a hearing Carrizales attended, a military court charged Marin with treason, instigating rebellion and violating decorum. Agents then took Marin away. He remained incommunicado for 78 days.

“I didn’t know if he was alive or dead,” said Carrizales.

Marin remains detained, and his wife continues to work for his release. Venezuelan officials haven’t publicly commented on the case or shown Marin’s lawyers the alleged video. No trial date has been set.

“They fear him,” Carrizales said. “He is an obvious leader within the armed forces. That’s why they arrested him.”