WASHINGTON — Jeff Sessions was in his office, looking unusually deflated. He had just received another public lashing from President Donald Trump.

Trump had browbeaten his attorney general for months after Sessions' decision to step aside from the intensifying Russia investigation. Never mind that Sessions has proved fiercely devoted to his boss, carrying out Trump's agenda while giving him credit every step of the way. Trump was unforgiving.

This attack came on an autumn day, and Sessions discussed it with a longtime friend and adviser who had stopped by to chat.

Get Breaking News Delivered to Your Inbox

Sessions shrugged. "I do the best I can," he said. Then he got back to work.

And, somewhat surprisingly, he's still working.

Sessions will soon mark his first year on the job, having survived a barrage of insults from Trump, antipathy from some Justice Department employees and even calls from some fellow Republicans for him to resign. Last week, America's top law enforcement officer was himself questioned as part of special counsel Robert Mueller's investigation into possible obstruction of justice and Trump campaign ties to Russian meddling in the 2016 election.

Trump's relentless attacks have been a wearing distraction, say friends and associates of the former Alabama senator. The Associated Press interviewed more than a dozen of them, many of whom spoke on condition of anonymity to discuss private interactions.

What keeps him going, friends say, is his Methodist faith, support from his wife and his awareness that, at age 71, leading the Justice Department is his best and perhaps final chance to carry out the policy changes he long has sought.

Sessions, the first senator to endorse Trump's candidacy, declined to be interviewed for this story but did agree to respond to written questions. He did not directly address his personal relationship with Trump but said his first year was marked by progress on a number of Trump's priorities: fighting crime, combating gangs and helping police.

"We are doing what the people sent us here to do," he said.

While Sessions is proud of his first year, friends see signs of stress. At an annual Justice Department Christmas party, one friend noted, the usually upbeat attorney general looked sullen and tired.

"We have talked about some of the difficult times he's had since he has been attorney general," said the Senate's second-ranking Republican, John Cornyn of Texas, a Sessions' confidant. "My comment to him was, as long as you're doing the right thing, I don't think you have anything to apologize for."

What Sessions sees as doing the right thing, though, often appears to others as doing Trump's bidding.

Critics say Sessions is too loyal, dangerously politicizing his department in an effort to appease Trump. Sessions told senior prosecutors to look into Hillary Clinton's activities after Trump demanded investigations of his 2016 Democratic rival, and he has been eager to pursue investigations into Trump grievances, such as media leaks. Lawmakers accuse Sessions of stonewalling congressional committees investigating the Trump campaign by repeatedly saying he doesn't recall key events.

Some say Sessions' public silence in the face of Trump's assaults on the department is demoralizing to employees and threatens its independence from the White House. Sessions said Friday that it's the department's responsibility to identify past mistakes and that a "culture of defensiveness is not acceptable."

"It seems he recognizes he is in such a weakened position, if he wants to stay in Trump's good graces he has to at least make a show of responding to Trump's demands, and that's extremely dangerous," said William Yeomans, who spent nearly 30 years at the department under Democratic and Republican administrations.

One example that raised eyebrows: Sessions' plan to confront the opioid crisis hews so closely to Trump's that White House aide Kellyanne Conway was on hand in the Justice Department's seventh-floor conference room when he announced it.

Sessions declined to address specific actions by his department but said it carries out "the law without regard to the political consequences or to poll numbers or who benefits and who doesn't," and Trump supports that.

Even if Sessions is complying with Trump's demands and pursuing his agenda, the attorney general has yet to find himself back in favor with the president. Before Sessions' decision to withdraw from the Russia investigation, Trump used to call Sessions periodically and seek his counsel. Now the two men rarely speak, and Sessions at times has resorted to asking West Wing aides to pass messages to Trump.

The rupture stems from Sessions' move on March 2 to step aside from that investigation after acknowledging he had had two previously undisclosed encounters with the Russian ambassador in Washington during Trump's campaign. Sessions said it would be improper for him to oversee an investigation into a campaign in which he played a prominent role.

Trump was furious. Sessions had disregarded a plea from Trump's White House lawyer, Don McGahn, who, at Trump's request, had urged the attorney general to retain oversight of the investigation. But by then, Sessions had already consulted with ethics officials and had made up his mind. Sessions' action left Trump without a close political appointee keeping a hand in the investigation of his campaign,

Sessions offered to resign. Trump declined to accept it. Sacking Sessions would have been politically perilous for the president.

But the barrage of tweets and public and private comments from Trump haven't ended. He disparaged Sessions in comparisons with Eric Holder, whom Trump says he respects for protecting President Barack Obama while serving as attorney general.

Sessions has endured with a courtly stoicism. If he's frustrated, friends said, he mostly keeps it to himself. At a recent get-together with Terry Lathan, a friend and chairwoman of the Alabama Republican Party, Sessions seemed more interested in what was going on back home than in complaining about job pressures.

"He's not going to sit around and yank the president's tie in private conversation with a group of his buddies," said Ken Blackwell, a domestic policy adviser to Trump's transition team who has known Sessions for years. "He's more like, this is what we need to get done, how do we get it done?"

Trump's antagonism has distressed Sessions' friends and supporters because they don't believe Sessions' stepping aside from the Russia investigation was a close call. One Sessions' ally said the attorney general's attitude remains that he is going to work 18-hour days to promote the administration's agenda.

Trump's priorities reflect the interests Sessions long has advocated, first as a federal prosecutor and then as a senator: illegal immigration, violent crime, illegal drugs, defending the rights of those who say they've been discriminated against based on religion.

"President Trump knows how to give clear orders, and he told us to reduce crime, take on the gangs and cartels, and back the men and women in blue," Sessions said. "The good news for us is that these directives are exactly what I want to do."

That agenda has unsettled liberals who say Sessions' focus on tough prosecutions marks a return to failed tactics that unduly hurt minorities and the poor. They say his rollbacks of protections for gay and transgender people amount to discrimination.

For Sessions, there's satisfaction in being able to reverse Obama-era policies that he and other conservatives say flouted the will of Congress. "The progress he has made has been very gratifying to him," said former Attorney General Ed Meese, who sees Sessions periodically.

Sessions takes pride in his many visits to U.S. attorney offices, where he speaks with local authorities, some of his most ardent fans, about how the federal government can help them. During a particularly tense stretch in November, when Sessions faced attacks from Trump and members of Congress, department officials held a call urging law enforcement groups to be vocally supportive of him, a person familiar with the call said.

Jonathan Thompson, executive director of the National Sheriffs' Association, recalled a December meeting when Sessions said he had to cut his appearance short. His voice was hoarse and he lamented his full schedule.

"He said, 'I wish I could sit here and talk with you all day,'" before his staff moved him along, said Thompson.