In his bid for president, Ted Cruz has sought to capitalize on voters’ anti-Washington mood by highlighting his victories as Texas solicitor general and his fights on the Senate floor. But only rarely does Cruz acknowledge a seven-year period of his career when he was not an outsider but an ambitious upstart climbing the Washington ranks from within.

Those formative years are often left out of the Texas senator’s story as he tells it on the campaign trail. “I spent all week in Washington, D.C.,” he likes to say, “and it’s great to be back in America.”

But Cruz’s early years working in or for Washington were no less pivotal in establishing his professional arc than his better-known tenure as solicitor general or his polarizing first term in the U.S. Senate. The former made possible the latter.

Ted Cruz arrived in Washington, D.C., in 1996 at age 25 as a law clerk to Supreme Court Chief Justice William Rehnquist. On the stump, Cruz has railed against today’s high court for its “judicial activism.” But his clerkship was something of a dream job for the young attorney, who had obsessively studied the Constitution since he was barely a teenager.

Rehnquist selected his clerks not only on the basis of their qualifications, but also on the strength of their chemistry with him and their fit with the ethos of his office. He liked clerks who would do the job well, of course, but also people with whom he could hang out. Cruz jelled on the strength of his sense of humor and his intellect — but he was not as low-key as the chief justice, and young Cruz’s personality could be abrasive. A champion debater at Princeton, he had a penchant for argument that had earned him foes at Harvard Law School, some of whom became fellow clerks on the Supreme Court. Within Rehnquist’s office, however, there was an understanding that Cruz’s arguments weren’t malicious.

“People who have been debaters, they can separate ideology from their personality,” said one former colleague on the court. “For [Cruz], it wasn’t personal to argue.”

The term was a high-octane one: The court tackled the question of presidential immunity in a lawsuit by Paula Corbin Jones against Bill Clinton (it ruled in the plaintiff’s favor); struck down a law designed to protect religious freedom; ruled against a key component of the Brady gun law; and rejected a law to curb indecent content on the Internet on free speech grounds.

Rehnquist’s clerks divided up their cases via a fantasy-football-esque draft, but tradition dictates that clerks do not publicly discuss what cases they tackled. Cruz’s campaign did not respond to a request for details about his cases, nor did he discuss these specifics in his book, “A Time for Truth.”

In conversations with colleagues at the time, Cruz discussed an interest in steering his legal career toward public service, and perhaps eventually returning to Texas. But after his clerkship, he chose to remain in D.C. He landed a job with Cooper, Carvin & Rosenthal, a now-defunct boutique law firm with a conservative bent and deep connections to the Republican establishment in Washington.

“He had a sterling resume,” said Mike Carvin, one of the firm’s partners, who is now a partner at Jones Day along with Ben Ginsberg, another well-known Republican attorney. With Carvin, Cruz represented Rep. John Boehner in a lawsuit against Rep. Jim McDermott, a Democrat who Boehner said leaked his cellphone conversations to the media.

Cruz assisted another partner, Charles Cooper, in representing the National Rifle Association on a range of gun-rights cases. Cruz also prepared Cooper, a fellow former Rehnquist clerk, for congressional testimony during impeachment proceedings against President Clinton.

Cruz began to wade into politics during his time at Cooper, Carvin. The firm focused its work on public policy issues. And Cooper and Carvin themselves were both well connected in Washington and working on a volunteer basis for George W. Bush’s presidential campaign. In 1998, Cruz began raising money for George W. Bush’s gubernatorial race. And in June 1999, at a fundraiser for Bush’s presidential campaign, a law school classmate introduced Cruz to Josh Bolten, Bush’s campaign policy director.

“The next day, I met with Josh for a couple of hours,” Cruz recalled in his book, “and next thing I knew I had a job on the campaign, as one of the domestic policy advisors to George W. Bush.”

When Cruz decided to leave Cooper, Carvin to join Bush’s campaign, he did so “with our blessing,” Cooper said. “If Bush hadn’t prevailed, we would have insisted that he would come back.”

But Bush did prevail — to Cruz’s benefit. The young lawyer played a central role in drafting domestic policy for Bush and answering his questions about issues. Some of Cruz’s memos have resurfaced during this presidential primary, including one he authored about immigration, in which he urged Bush to oppose amnesty for undocumented immigrants “at this time.”

After the 2000 vote left Florida hanging in the balance, Bolten tapped Cruz, one of the few campaign aides with legal experience and who had worked for the Supreme Court, to help navigate the recount process. “Ted was at the center of it,” recalled Cooper, whose firm worked with the campaign on that legal battle.

“By the accident of being in that place I found myself, there was sort of a small leadership team that consisted of Jim Baker and Josh Bolten and Ted Olson and George Terwilliger and Ben Ginsberg and me,” Cruz told The New Yorker in 2014. “And I’m twenty-nine years old, this kid, and all of these other folks are Cabinet members and masters of the universe.”

When Bush eventually won the recount, and the presidency, Cruz hoped for and expected a role in the White House. But he was instead sent to the Department of Justice under Attorney General John Ashcroft — a result, by Cruz’s own admission, of having been “far too cocky for my own good” during the campaign, he wrote in his book.

To one associate who spoke to RCP, Cruz was even more blunt.

“I was an asshole,” Cruz told his friend.

After just six months, Cruz moved from a job at Justice to the Federal Trade Commission. Although it was a less prestigious role, it gave Cruz the chance to work with someone he’d gotten to know during the Bush campaign, incoming FTC commissioner Timothy Muris.

At the FTC, Cruz was the director of the office of policy planning, a small think tank within the commission that reported directly to the chairman and focused on long-term policy development. The job put Cruz in the thick of the federal bureaucracy, and he took to it: Jerry Ellig, the deputy director who worked alongside Cruz, recalled him having been genuinely passionate about the agency’s mission and his work there.

“It is just great to wake up every morning and come into the office when I know that our job is to fight for free markets and competition,” Cruz would say, according to Ellig.

With commissioners of both parties atop the FTC, the role did not permit the partisan grandstanding for which Cruz is best known today. Instead, Cruz established himself at the FTC as a reliable consensus builder.

“We’d start a project and he’d say at some point, ‘How do we do this project in a way that all the commissioners would be happy with it?’” Ellig recalled. “He was certainly sensitive to the need for consensus and tried to design things so they would bring consensus.”

One of Cruz’s ideas that won the approval of all five commissioners, as many of his pitches did, was for a three-day public workshop discussing potential barriers to e-commerce. At the event in October 2002, Rep. Cliff Stearns, at the time chairman of the subcommittee on commerce, manufacturing and trade, dubbed him “Czar Cruz of the Internet.”

But the role was not what Cruz had envisioned for himself in Washington. He yearned to be a power player.

“I desperately wanted to be a real leader in the Bush administration—to have a senior post like so many of my campaign colleagues,” Cruz wrote in his book. “When that didn’t happen, and it became clear it wasn’t going to happen, it was a crushing blow.”

Marginalized in the administration, his ambitions stalling, Cruz decided he needed to upend the power structure. He would find another way to the top in Washington. And in 2003, when an opportunity arose for Cruz to become the Texas solicitor general, he took it.

“That was the point when he realized his career was not ascending the way he wanted, and he needed to make a change,” said a former confidant. “He began to engineer a path on the outside.”

Even on the outside, however, Cruz maintained links to the inside. During his tenure as solicitor general, he discussed his political future over a four-hour breakfast with Karl Rove, Cruz recalled in his book. As Cruz prepared to run for Senate in Texas a few years later, George P. Bush (the eldest son of Jeb Bush), at the time working in private equity and steering his Hispanic Republicans of Texas political action committee, was in Cruz’s innermost circle.

During Cruz’s campaign, running as the anti-establishment foil to Lt. Gov. David Dewhurst, George P. Bush invited him to the family compound in Kennebunkport, Maine, where he received support for his bid from former President George H.W. Bush. Cruz ultimately declined to publicize this, he wrote in his book, because Rove demanded he not.

But Cruz established his own narrative in the campaign, which highlighted his work as solicitor general and deemphasized other parts of his resume.

“We have way too many lawyers in Congress,” Cruz said in one radio interview during his Senate campaign. “But I’m not running as a lawyer. I’m running as a fighter.”

Although he returned to Washington as an outsider, vestiges remained of his history in the establishment. He accepted a role as a vice chairman for the National Republican Senatorial Committee, helping party leaders raise money. But he ultimately abandoned that position, citing in his book qualms about favoring incumbents over primary challengers.

Cruz had initially appeared willing and even eager to build relationships with leaders in the GOP. During a speech to CPAC in 2011, during his Senate campaign, Cruz effusively characterized Paul Ryan as a “personal friend.” Last year, the two men co-authored a Wall Street Journal op-ed pushing for passage of Trade Promotion Authority. But shortly thereafter, Cruz reneged on his support for TPA. When asked on “Meet the Press” last year whether Ryan is a “true conservative,” Cruz dodged, calling it "question for the House Republican Conference."

Among some of Cruz’s former colleagues from his seven-year stint on the inside of Washington, his evolution makes sense.

“When you’re a manager in a federal agency reporting directly to the chairman,” observed Ellig, Cruz’s FTC colleague, “you have different constraints and opportunities than when you are one of 100 senators and the junior senator from your state.”

And Cruz has maintained some of his earliest professional relationships. Cooper, a partner from his first law firm, has helped raise money for Cruz’s presidential bid, hosting a fundraiser at his Washington, D.C., home last year. But many other early relationships have soured. Former President George W. Bush reportedly said of Cruz at a private audience with donors last year: “I just don’t like the guy.”

Privately, Karl Rove has conveyed similar feelings. Broadly, there is a sense among some Republicans who knew Cruz in his early career that his outsider narrative is disingenuous. But Cruz, the champion debater, has never felt an emotional tie to his arguments. And Cruz the performer understands the mood of his audience.

“In both law and politics,” he told The New Yorker last year, “I think the essential battle is the meta-battle of framing the narrative.”

And Cruz’s Washington career no longer fits in the picture.