Sen. Ted Cruz spent his years at Harvard Law School working to secure a Supreme Court clerkship and then made his name as a lawyer by arguing in front of the body nine times.

But now, as a presidential candidate seeking support from the right wing of his party, Cruz (R-Tex.) has made excoriating the high court a central part of his campaign.

The attacks were prompted by the landmark opinions from the high court in late June that legalized same-sex marriage nationwide and upheld key provisions of the Affordable Care Act.

Calling it “some of the darkest 24 hours in our nation’s history,” Cruz has repeatedly characterized the rulings as political decisions that imperil the Constitution and has accused justices of violating their oaths and federal law. He has called for a constitutional amendment requiring members of the Supreme Court to undergo judicial retention elections and has suggested that only the people directly involved in the gay-marriage case are bound by the justices’ ruling.

“To see the court behaving as it is today, as a super-legislature, simply enacting the policy preferences of the elite judges who are serving upon it, is a profound betrayal of their judicial oaths of office and of the constitutional design that has protected our liberty for over two centuries,” Cruz said in an interview over the weekend.

An angry Ted Cruz (R-Tex.) took to the Senate floor to express his disapproval of the court’s decision to uphold a key provision of Obamacare, calling the justices "robed Houdinis." (SenTedCruz/YouTube)

The rhetoric is striking not only for its sharp tone but because it comes from a man who spent years trying to get inside the Supreme Court. He accomplished his goal by serving as a law clerk for Chief Justice William H. Rehnquist from 1996 to 1997. He became a member of the Supreme Court bar in 2002 and argued before the body as solicitor general of Texas and as a private lawyer. He also has written more than 80 briefs for the court.

“In high school, I decided that being a law clerk at the Supreme Court, working alongside nine of the most revered judges in the land, would be one of the coolest jobs in the world,” Cruz writes in his book “A Time for Truth.”

Speaking to The Washington Post in Greenville, S.C., on Saturday, Cruz said it “saddens” him to be calling for fundamental reform to “rein in” the court.

“It is an institution that I have spent the majority of my adult life working in and around. I know the justices personally and respect and admire a number of them,” Cruz said. “But no one in their right mind would establish a system of government where every major contested public policy issue is decided by the decree of five unelected lawyers. That’s not a rational way to govern our society.”

Cruz declined to say which justices he would like to see removed from the court in a judicial retention election. “One step at a time,” he said.

A constitutional amendment requires a two-thirds majority vote in the Senate and the House, then ratification by three-quarters of the states. Many constitutional lawyers say Cruz’s proposal has little chance of advancing.

Presidential candidate Ted Cruz writes in his new book that clerking at the Supreme Court was ‘one of the coolest jobs in the world.’ The Texas senator is now harshly criticizing the high court for its gay marriage and health-care rulings. (Erik S. Lesser/EPA)

“A constitutional amendment to change Article III of the Constitution in this fashion has virtually no chance of succeeding,” Theodore B. Olson, who served as solicitor general from 2001 to 2004 under President George W. Bush, said by e-mail. “I would think that most graduates of the Harvard Law School know that.”

“The last thing we need is to make judges more like politicians, having to run for retention,” said Randy Barnett, a professor at Georgetown Law School. Barnett is informally advising the presidential campaign of Sen. Rand Paul (R-Ky.).

Cruz has singled out two justices for particular criticism: Anthony M. Kennedy, the author of the decision on same-sex marriage, and Chief Justice John G. Roberts Jr., who wrote the opinion upholding the health-care law and joined in a separate pro-ACA ruling in 2012. Cruz cites Roberts’s testimony during his confirmation hearing that he would be an “umpire” who applied rules, not someone who made them. Cruz said Roberts has now “put on an Obama jersey” and joined the administration.

The assertions are all the more striking given the personal history of the two men. Cruz invited Roberts, then a lawyer in private practice, to be part of the litigation team working on the Florida vote recount for George W. Bush in 2000.

“Chief Justice Roberts and I have been friends for 20 years,” Cruz said. “His decisions on the two Obamacare cases have been heartbreaking . . . because he’s a talented enough lawyer that he knows exactly what he’s doing.”

Asked if he believes Roberts should be impeached for, in Cruz’s view, violating his judicial oath, the senator said impeachment is “no longer an effective check and balance.” He said that is why he is calling for a judicial retention election.

Charles Fried, a Harvard Law professor who was solicitor general under Ronald Reagan and wrote one of Cruz’s recommendations for his Supreme Court clerkship, said Cruz’s call for a constitutional amendment and his harsh criticism of the court pale in comparison to dissents by Justice Antonin Scalia, who called the marriage decision “a threat to American democracy.”

“Just compare what he says to what Scalia says in his dissents and tell me which you think is more vituperative,” Fried said of Cruz. “This isn’t vituperative. It is an opinion. It is a judgment, a legal judgment. It isn’t correct — I mean I don’t agree with it — but it’s not out of line.”

Fried said he is more wary of Cruz’s assertions that only the parties to a judicial case must follow its rulings.

“The suggestion that town clerks and justices of the peace and so on don’t have to follow this law — that’s a more dangerous proposition,” Fried said.

David Vladeck, a professor at Georgetown Law School, said Cruz is advocating “massive resistance to a Supreme Court decision,” which is the same “argument we saw after Brown v. Board of Education,” the 1954 ruling against segregated schools.

“For someone who is a member of the bar, he’s not going to stay there long, because he’s advocating disobedience to the law, and lawyers aren’t supposed to be doing that,” Vladeck said.

Cruz said he believes there will be a movement to reverse the two decisions, and he criticized other 2016 candidates for suggesting that Republicans should “surrender and move on.”