US officials tried to influence Spanish prosecutors and government officials to head off court investigations into Guantánamo Bay torture allegations, secret CIA "extraordinary rendition" flights and the killing of a Spanish journalist by US troops in Iraq, according to secret US diplomatic cables.

Among their biggest worries were investigations pursued by the magistrate Baltasar Garzón, who US officials described as having "an anti-American streak".

"We are certainly under no illusions about the individual with whom we are dealing," they said after he opened an investigation into torture at Guantánamo Bay prison camp. "Judge Garzon has been a storied and controversial figure in recent Spanish history, whose ambition and pursuit of the spotlight may be without rival."

The revelations contained in the leaked documents will be embarrassing to Spanish prosecutors who shared information on cases they were involved in, and whose identities the Americans wanted protected.

They included the attorney general, Candido Conde-Pumpido, national court chief prosecutor, Javier Zaragoza, and fellow prosecutor Vicente González Mota, responsible for the CIA flights affair.

Zaragoza is revealed as a valuable source who accuses Garzón of opening some human rights cases in order to "drum up more speaking fees". He proved to be an ally as the US tried to stem a flood of investigations at Spain's national court – one of the world's most vigorous courts in exercising international jurisdiction over human rights crimes.

A major worry was a torture case brought by a Spanish non-governmental organisation against six senior Bush administration officials, including the former attorney general Alberto Gonzales.

Senator Mel Martinez, a former Republican party chairman, and the US embassy's charge d'affaires visited the Spanish foreign ministry to warn the investigation would have consequences. "Martinez and the charge underscored that the prosecutions would ... have an enormous impact on the bilateral relationship," the officials reported.

Officials in Madrid discussed with Zaragoza ways in which a US investigation into the same allegations might be opened in order to force the Spanish court to close its own case. "Zaragoza has also told us that if a proceeding regarding this matter were underway in the US, that would effectively bar proceedings in Spain. We intend to further explore this option with him informally," they said.

Garzón, who opened a separate torture investigation, was deemed to put self-promotion first. "We suspect Garzón will wring all the publicity he can from the case unless and until he is forced to give it up," said the officials.

"Zaragoza said he had challenged Garzón directly and personally on this latest case, asking if he was trying to drum up more speaking fees," they reported.

They noted that Garzón was already in hot water over his investigation into human rights crimes committed under Spain's former dictator General Francisco Franco. As a result Garzón now looks set to be removed from his job by supreme court judges next year.

"Zaragoza doubts Garzón will risk a second such complaint," they said.

But US officials worried he would go down fighting. "It is hard for us to see why the publicity-loving Garzón would shut off his headline-generating machine unless forced to do so," they reported. "We also fear Garzón – far from being deterred by threats of disciplinary action – may welcome the chance for martyrdom, knowing the case will attract worldwide attention."

When another Spanish magistrate began investigating the alleged use of a Spanish airport for secret CIA flights carrying terror suspects, officials noted that US policy was to deal with these cases in closed-door conversations with governments.

They were especially alarmed when magistrates and prosecutors in both Spain and Germany began comparing notes. "This co-ordination among independent investigators will complicate our efforts to manage this case at a discreet government-to-government level," they warned.

Officials noted, however, that their own government had not explicitly denied the allegations. "Our ability to beat down this story is constrained by the fact that we do not ourselves know, factually, what might have transpired five or six years ago as the battles in Afghanistan and Iraq began yielding large numbers of potentially dangerous terrorist detainees and unlawful combatants," they observed.

"Baring (sic) a categorical statement from the US government that no detainees passed through Spain – and we understand that might be undesirable from a policy standpoint even if factually correct – nothing but time is going to make this go away," they said.

González Mota, who was handling the CIA flights, was a valuable source. "The prosecutors do not intend to request information on this case from the embassy or from the US government in general," US officials said after a conversation with him.

When another Spanish magistrate issued arrest warrants for three US soldiers involved in the death of Spanish television cameraman José Couso in Baghdad, senior ministers in Spain's socialist government moved to stop the investigation. Couso was killed in April 2003 alongside Reuters cameraman Taras Protsyuk when a tank opened fire on a hotel known to accommodate journalists.

"Top ministers moved quickly to let us know that the government is working to resolve this situation," the officials reported, naming the deputy prime minister, María Teresa Fernández de la Vega, foreign minister, Miguel Angel Moratinos, and justice minister, Juan Fernando López Aguilar.

"The [Spanish] government must act carefully as it tries to influence Spain's fiercely independent judiciary," they noted. " In order to avoid aggravating the situation, Spanish government leaders must publicly show their respect for the independent workings of the courts."