This article is from the archive of our partner National Journal

Long before he launched a presidential campaign, Ted Cruz gave his debate skills a workout in front of the toughest audience in Washington: the Supreme Court.

Cruz, who on Monday became the first official candidate of 2016, has argued nine cases before the high court. And those arguments have a lot in common with his time in elected office—namely, aggressively conservative positions, sometimes challenging the federal government, with decidedly uneven results.

It's not a big leap from this, in 2007—"In over 200 years of our nation's history, I'm not aware of any other directive from the president directly to the state courts"—to his presidential announcement asking supporters to text his campaign the word "Constitution."

All but one of Cruz's appearances came while he was solicitor general of Texas from 2003 to 2008, when he was obligated to defend whatever the state was doing. But a look at his time in front of the Court shows it's the same Ted Cruz.

(RELATED: Ted Cruz Has Been Running for President for Years in the Senate)

In his first case before the Supreme Court, he went hard on states' rights—and lost hard, too.

Cruz was trying to convince the justices that it would be unconstitutional to enforce an agreement Texas had made to improve its Medicaid program. The state had been sued a few years earlier over gaps in Medicaid coverage for children; a group of mothers said the state wasn't living up to federal standards for the program.

After a long negotiation, the suit was settled with a consent decree—a roughly 80-page agreement that spelled out how Texas would improve its Medicaid program to come into compliance with federal standards. But the plaintiffs didn't think Texas was making the improvements it had agreed to, and they sued again to enforce the decree.

Cruz argued that enforcing the agreement would violate the 11th Amendment, which gives the states sovereign immunity. But the Court's conservatives weren't buying it.

"They gave up their lawsuit and, you know, packed up and went home. And you're telling them that they accomplished nothing by doing that," Justice Antonin Scalia said to Cruz during oral arguments. "Why would the other side ever accept such a consent decree? It's crazy."

Cruz lost, 9-0.

(RELATED: Ted Cruz, the Obamacare Candidate)

Just a few years later, though, he was back before the high court to argue the case that would ultimately be his biggest victory as solicitor general: Texas's repeated efforts to execute Jose Medellin, a Mexican national convicted of rape and murder.

Medellin's case was a big part of Cruz's Senate campaign in 2012, and it is sort of a perfect storm of conservative issues. It allowed Cruz to simultaneously defend a death sentence, put American courts before international ones, and even take a swipe at the president for overstepping his authority.

Medellin was sentenced to death for his role in the rape and murder of two teenage girls. He confessed to the crimes, even after local police read him his Miranda rights.

But the police did not inform Medellin that, under the terms of a 1969 treaty known as the Vienna Convention, foreign nationals arrested inside the U.S. have the right to seek assistance from their home country's consulates.

The International Court of Justice ruled that the U.S. had violated the Vienna Convention by failing to notify more than 50 suspects, including Medellin, of their right to call their consulates. The U.S. had to reconsider those convictions, the International Court said.

And though it wasn't clear whether American courts were actually bound by that decision, then-President George W. Bush said state courts in the U.S. would respect the ICJ's ruling.

Cruz urged the Supreme Court to disregard both the international ruling and Bush's assessment of it, and to let Texas's sentence stand.

(RELATED: Ted Cruz Opens 2016 As the Election's Self-Declared Conservative Champion)

"This is a very curious assertion of presidential power. Because the presidential power is not directed at the federal courts. It is directed at the state courts, and the state courts alone. And I would submit is the only instance I'm aware of, of a federal mandate that falls only on the states, singles out the states, and commandeers those judges. In over 200 years of our nation's history, I'm not aware of any other directive from the president directly to the state courts and state judges," Cruz said during oral arguments.

The Supreme Court ultimately sided with Cruz, in a 6-3 ruling written by Chief Justice John Roberts.

Cruz was also largely successful in defending Texas's congressional redistricting in 2003. Democrats in the state challenged the new map, arguing that the state violated both the Constitution and the Voting Rights Act by carving Latino voters out of some districts.

The Court ultimately ruled that the map wasn't unconstitutional but that certain districts' boundaries were improper—a point Justice Anthony Kennedy had pressed during Cruz's oral arguments.

"Do you want this Court to say that it's constitutionally permissible to take away a number of minority voters from the district, but leave just enough so that it looks like a minority? Is that a permissible use of race? It seems to me that's an affront and an insult," Kennedy said to Cruz.

(RELATED: How Ted Cruz Will Pull the GOP Primary Right)

Aside from the redistricting case, Cruz spent most of his time before the Supreme Court defending tough criminal sentences, including the death penalty (not too surprising, for the Texas solicitor general).

The death penalty was the central issue in Cruz's last case as solicitor general, in which he and other attorneys on his side missed a critical fact that might have swung the case their way.

Cruz jumped into a 2008 case over a Louisiana law that sentenced child rapists to death. The Court ultimately ruled that the sentence was unconstitutional, relying in part on the fact that only a small handful of states allowed it.

During oral arguments, Cruz urged the justices to defer to those states, and said that more jurisdictions might adopt penalties similar to Louisiana's.

"What we are advocating is that there is an evolving understanding of the enormous, unique, irreparable harms to children, and it's elected legislatures that can sit and listen to those advocates from the groups, listen to the empirical data, consider the deterrence effect—consider all of these and decide one way or the other," Cruz said. "I would fully expect, in time, some states would act to establish capital punishment and others would not. And that that's precisely how the laboratories of democracy should operate."

But the lawyers arguing in favor of the death penalty missed a potentially important fact: The U.S. military had changed its code to allow capital punishment for child rape. The fact that the federal government had accepted the penalty might have undercut Kennedy's argument that it fell outside the "evolving standards of decency" by which capital punishment is judged.

Cruz told The New York Times after the ruling that the change in military rules had "eluded everyone's research," and that he didn't think the Court would change its underlying decision, even if the oversight was corrected.

This article is from the archive of our partner National Journal.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.