WASHINGTON (Reuters) - Republican presidential candidate Ted Cruz often tells supporters about his Supreme Court win against the federal government in 2008, defending Texas’ right to execute a Mexican man for murder, as evidence of his conservative and anti-establishment credentials. But there is one part of the story that goes untold. The Medellin v. Texas case, decided when Cruz was the state’s solicitor general, set the stage for years of diplomatic tension between the United States and its southern neighbor. Mexico has publicly protested U.S. executions of its citizens over the years, but interviews with diplomats and reviews of official Mexican government communiqués reveal that the turmoil caused by the Medellin case ran deeper, coming up at nearly every meeting between the United States and Mexico and leading to an official protest to the United Nations Security Council in 2014. Given the level of frustration, Cruz’s role in the court battle raises questions about U.S.-Mexico relations if he were to beat billionaire Donald Trump to the Republican nomination and win the U.S. presidential election in November.    “I think relations would be complicated with a President Cruz,” said Sergio Alcocer, who was Mexico’s deputy foreign minister responsible for North America between 2012-2015. Alcocer praised Cruz as intelligent and pragmatic but said the senator was too inflexible on issues like immigration and the death penalty. “Cruz takes certain positions that are very clearly defined. And he’s much more conservative, much more dogmatic than Trump,” Alcocer said. A Cruz campaign official did not respond to requests for comment. In Mexico City, a foreign ministry spokesman said Mexico had no preference among the U.S. presidential candidates and would not comment on the election. In the Medellin case, Cruz defended the death sentence a Texas court imposed on Mexican citizen Jose Ernesto Medellin after he was convicted in 1994 for his role in the gang rape and strangling of two teenage girls in a Houston park.  In 2004, the International Court of Justice of the United Nations ruled that Texas and other states had violated the Vienna Convention by failing to notify Medellin and 50 other Mexicans on death row of their right to contact the Mexican consulate after arrest. President George W. Bush ordered Texas and other states to review the sentences. Cruz argued that, while the United States had submitted to the international court’s decisions, the White House could not implement an international agreement that required states to change their court procedures without action by Congress. The Supreme Court agreed in a 6-3 decision. Winning the case raised Cruz’s profile in conservative circles. He has recently said he would appoint justices who would narrowly interpret the Constitution - as he did in the Medellin case - a crucial talking point in the election following the death of Supreme Court conservative icon Antonin Scalia.  “It was an unusual thing at the time for the state of Texas to be standing up against the president of the United States in front of the Supreme Court, particularly when that president was a Texan and a Republican and the former governor of this state,” Cruz told cheering supporters at a Houston rally in February, one of the many times he has brought up the case. The Supreme Court ruling removed a potential legal barrier to three more executions of Mexican nationals in Texas who had been part of the same international court case as Medellin, even as U.S. allies such as the European Union and Switzerland criticized what they saw as ongoing treaty violations.  Mexico pressed U.S. officials and Congress to follow the international court’s directive and require states to review death sentences where people had been denied consular access. “The issue came up as one of the top few issues (Mexico) raised in almost every bilateral meeting we had,” said Harold Hongju Koh, who was legal adviser to the U.S. State Department from 2009-2013. Alcocer, the former Mexican deputy foreign minister, confirmed the issue of consular access was raised during negotiations on other cross-border issues like the extradition of criminals.  “It’s not resolved, and it’s something that Mexico needs to keep insisting on,” he said in an interview. Mexican officials said both the Bush and Obama administrations had been open to working on the issue. U.S. State Department officials supported consular-access legislation introduced in the Senate, but that was not enough to spur Congress to resolve the issue. Texas executed Medellin in August 2008, five months after the Supreme Court decision, drawing swift criticism from the United Nations court.  Three years later, as Texas prepared to execute another Mexican national who had not received consular access, Mexico’s then-ambassador to the United States, Arturo Sarukhan, wrote to U.S. Secretary of State Hillary Clinton saying the action would “seriously jeopardize” cooperation on a range of issues. “It serves neither the United States nor the Mexico-U.S. relationship if the U.S. cannot live up to its treaty obligations,” said the letter, which was reviewed by Reuters.  In 2013, Mexico warned Washington in another letter that the executions of Mexican nationals who had been denied consular access would mean “our whole forward-looking bilateral engagement could be questioned.” A year later the government wrote to the president of the United Nations’ Security Council expressing indignation over the executions of Mexican citizens in violation of the international court directive.  Sarukhan, the former Mexican ambassador, said Mexico had few options to put pressure on the United States without harming cooperation in other areas.  “March 31st marks now 12 years since the decision was rendered and the United States is yet to comply with its international obligations,” the government said in a statement, responding to Reuters questions about the Medellin case and Cruz’s involvement in it. Critics of the Medellin ruling, and Cruz’s boasts about it, say Texas could have simply reviewed the sentences as the international court had asked.     “Texas could have provided that remedy 20 times over in the time that it took to litigate that case up and down through the Texas courts and the Supreme Court,” said Sandra Babcock, a law professor at Cornell University who was one of Medellin’s attorneys. “The long-term damage, the reputational damage to the United States is still ongoing.” But Cruz’s supporters dismiss such criticism. His job as solicitor general was to defend Texas, not to worry about the international implications, they say.  Texas Governor Greg Abbott, a former attorney general who was Cruz’s boss at the time of the Medellin case, introduced the presidential hopeful at the February rally in Houston.  “He fought against the United Nations, the world court and the United States of America itself to defend Texas’ sovereignty,” Abbott said to cheers. 