By the time Jeff Sessions appeared before the Senate to answer questions about his nomination to the federal bench, his reputation was in tatters.

Former colleagues had accused him of frequently making racist comments, such as accusing the NAACP of teaching “anti-American values” and agreeing with a comment that a white civil rights lawyer litigating voting rights cases was a “disgrace to his race.” With his nomination all but doomed, Sessions pleaded for a chance to salvage his reputation.

“I am not the Jeff Sessions my detractors have tried to create,” said Sessions, then a 39-year-old U.S. attorney from Alabama. “I am not a racist. I am not insensitive to blacks.”

Sessions’s defense didn’t work at the time. But, undeterred, he forged a career as a politician, becoming Alabama’s attorney general, a U.S. senator and, now, a key player in Donald Trump’s presidential campaign.

Sessions has spent his time in Washington largely on the edges of Republican politics. Although he has been a reliably conservative vote, Sessions has not been a leader in the Senate. His following comes not from soaring remarks on the Senate floor, but from coverage of his positions on conservative websites and appearances at policy conferences giving voice to an older and less diverse segment of the GOP than party leadership has recently attempted to court.

View Graphic Tell us how the Republican National Convention makes you feel, in emoji

As the GOP brass pushed for immigration reforms designed to make their party more appealing to Hispanics, Sessions championed the opposition.

But in the party of Trump, Sessions is at the center of the action. He was an early backer of the real estate mogul’s candidacy, when most Republican officials were denouncing Trump’s comments about Mexicans and his promise to build a wall on the southern border. He is one of Trump’s most trusted policy advisers, assisting with his selection of Indiana Gov. Mike Pence as his running mate. And with a prime-time speaking slot Monday night at the Republican National Convention, Sessions is a living symbol of an upside-down GOP in which a largely sideline player can become a heavyweight.

On Monday, for instance, Sessions observed a sea change in opinion of free trade and immigration, which have come under attack as economic populism has flared.

“I can feel, in the media and Congress, a greater respect for our discussion on the impact of these trade deals and illegal immigration,” Sessions said in an interview from the convention’s red-carpeted floor. Earlier Monday, he said on MSNBC’s “Morning Joe” that his votes in favor of past trade deals were “mistakes,” and he said House Speaker Paul D. Ryan “needs to change, just like I have.”

Sessions, now 69, was a young lawyer in Mobile, Ala., when President Ronald Reagan first tapped him in 1981 to be a U.S. attorney. The nomination to the federal district court came four years later — but any hope for a smooth confirmation by the Republican-led Senate was quickly dashed as the Judiciary Committee heard from Sessions’s former colleagues about his past remarks.

J. Gerald Hebert, then a Justice Department lawyer based in Washington, recalled visiting the Mobile office while working on voting rights cases and listening as Sessions sounded off on his view of black civil rights groups, at one point calling the NAACP a “commie pinko organization,” as Hebert recalled in a recent interview.

Thomas H. Figures, a black assistant U.S. attorney who worked under Sessions, told the committee that Sessions said he thought the Ku Klux Klan was okay until he learned its members smoked marijuana.

1 of 59 Full Screen Autoplay Close Skip Ad × What the first day of the Republican National Convention looks like View Photos Delegates and party leaders gather in Cleveland to name their presidential nominee. Caption Delegates and party leaders gather in Cleveland to name their presidential nominee. July 18, 2016 Melania Trump told the audience about her husband’s patriotism and the “love in the Trump family.” Ricky Carioti/The Washington Post Buy Photo Wait 1 second to continue.

Sessions’s defense was vigorous. He said the statement was not intended to signal support for the Klan. When pressed on an allegation that he had used the n-word to refer to a black county commissioner, Sessions said it was “the first I ever heard that.”

During his hearing, Sessions denied making certain controversial statements and said others had been misconstrued. He allowed that he could be “loose with my tongue on occasion.”

The committee voted 10 to 8 to block Sessions’s nomination, with two Republicans joining the Democrats to oppose him.

A Sessions spokesman did not respond to a request for comment regarding claims made during the confirmation process.

As Sessions rose through the political ranks in Alabama, the accusations did not linger as a front-burner controversy. His political opponents have made little mention of the hearing. When the allegations have arisen, he has defended himself by saying he was blocked from the federal bench for political reasons, and most recently, in 2014, he ran unopposed for reelection.

Vivian Davis Figures, the sister-in-law of the assistant U.S. attorney who testified against Sessions during the hearing and a Democratic state senator who ran against Sessions in 2008, said she and Sessions have had a friendly relationship. Sessions gave Figures tickets to Barack Obama’s inauguration in 2009, just after he had beaten her and won a third term, she said.

Susan Parker, a Democrat who mounted an unsuccessful challenge to Sessions’s reelection bid in 2002, called him a “gentleman,” saying he was polite to her when they faced off 14 years ago. During a televised debate, she said, she was suffering from a cold and needed a tissue. She joked that she would use it to dry her eyes when Sessions made her cry, and he replied: “Please don’t say that. That’s my nightmare. I promise I’ll be nice.”

She remembers being surprised when she learned that Sessions — “the ultimate conservative,” as she called him — was supporting Trump, who has been “all over the place,” she said. Parker’s own donor list is proof: Federal Election Commission filings show that he gave the Democrat $1,000 in her bid to unseat the man who is now his closest Senate ally.

His Southern manners notwithstanding, Sessions speaks his mind, said Terry Lathan, who chairs the Alabama Republican Party.

“The Jeff Sessions that I know isn’t quiet,” she said. “He’s respectful, but I have no doubt that when he speaks with Mr. Trump, he tells it like it is.”

On Capitol Hill, Sessions operated mostly in the background — until leaders in his party embraced a bipartisan immigration overhaul that would have put millions of unauthorized immigrants on a path to citizenship. In 2013, he was a hero to groups who oppose illegal immigration with his persistent speeches and behind-the-scenes maneuvering to undermine a measure that had the backing of prominent Republicans and the business lobby.

As the 2016 Republican primaries became dominated by outsiders, Sessions began to rise from a favorite of the hard right to a subject of praise on the campaign trail — not just at Trump rallies, but also by Sen. Ted Cruz (R-Tex.).

As Trump gained momentum last year, the two men appeared drawn to each other.

At a rally in Mobile last August, several months before Sessions would endorse him, Trump appeared with the senator, praising him as one of the few politicians he held in high regard, particularly when it came to immigration.

“We have a great politician here,” Trump said. “We have a man here who really helped me. . . . I sought his counsel because he’s been so spot on, he’s so highly respected.”

Sessions has helped craft Trump’s immigration platform, chaired his national security advisory committee, loaned him a top communications aide specializing in immigration and counseled him on whom to add to his ticket as vice president.

As Trump grappled with his vice-presidential decision during a fundraising trip to California last week, Sessions played the role of listener and travel companion, joining Trump on the flight to Los Angeles.

Even though Sessions himself was in play for the selection, he sat patiently with Trump as the candidate went through the upside and downside of picking Pence, according to a Republican familiar with the conversation who spoke on the condition of anonymity. A proven loyalist, Sessions is seen as a potential Cabinet secretary under a President Trump — perhaps heading the Justice Department or the Department of Homeland Security.

Jessica Vaughan, director of policy studies at the conservative Center for Immigration Studies, said she has been glad to see Trump consult Sessions on immigration policy — and would like for him to emulate the senator’s tone, as well.

“I do prefer that calm, respectful, measured tone on this issue,” she said, praising Sessions for speaking “without vitriol or bombast.”

While many of his Republican colleagues remain mute on the man who will claim their party’s nomination this week, Sessions said he was drawn to the candidate because of his willingness to buck the Republican establishment.

He credits Trump with forcing the GOP to rethink its long-held support for free trade.

“It’s not working out, and I think a lot of people are reevaluating,” said Sessions, who, as recently as 2011, favored the U.S.-Korea Free Trade Agreement when it cleared the Senate.

As Sessions has gained prominence in Trump’s campaign, his critics have pointed to the racially charged controversy around his failed judicial nomination to highlight Trump’s own race-related issues. The real estate mogul sparked a storm of protest recently when he retweeted an anti-Semitic symbol that had previously appeared on a white supremacist website.

Heidi Beirich, director of Southern Poverty Law Center’s Intelligence Project, which tracks hate group on the right and left, said Sessions has engaged in “hate speech” with incendiary comments about Muslims and immigrants. His role in Trump’s inner circle, she said, is evidence of the extent to which the Republican standard-bearer has “upset the rules of decency.” And she called Sessions’s newfound influence “a tragedy for American politics.”

Sessions recoiled at the suggestion that he has any racial bias. He said he has never associated with any white supremacist groups.

“Racism is totally unacceptable in America,” he said. “Everybody needs to be treated fairly and objectively.”

Lathan, the Alabama GOP chair, laughed off concerns about the senator’s racial views.

“With all due respect, you’re out of line to try to connect that dot at all,” she said. “That makes absolutely no sense to me.”

But Hebert, the former Justice Department attorney who testified against Sessoins’s nomination 30 years ago, said that Sessions’s words and deeds over the years have amplified his concerns. Sessions now sits on the Judiciary Committee, the body that refused him his judicial appointment.

“Many people in Alabama have said to me if we had just let him be a federal judge in Mobile, nobody would have heard of him,” Hebert said. “Being rejected then launched him into the U.S. Senate. They jokingly say we would be better off.”

Alice Crites and Robert Costa contributed to this report.