His loyalty to the boss severely tested but seemingly intact, U.S. Attorney General Jeff Sessions says he will stay in the job for as long as President Donald Trump wants him to serve.

Sessions told The Associated Press during a visit to El Salvador that he and Trump have a "harmony of values and beliefs" and he intends to stay and fight for the president's agenda "as long as he sees that as appropriate." His assessment came after a week of being berated by Trump in the most public fashion as a weak and ineffective leader.

"If he wants to make a change, he has every right," Sessions said in an interview outside the U.S. Embassy in San Salvador during a mission to increase international co-operation against the MS-13 gang. "I serve at the pleasure of the president. I've understood that from the day I took the job."

Congressional Republicans have rallied around Sessions, a former senator from Alabama, and expressed mortification at the humiliation visited on him by Trump in several interviews and a series of tweets.

Attorney General El Salvador

U.S. Attorney General Jeff Sessions walks past a cell during a tour of local police station and detention centre in San Salvador, El Salvador, on Thursday. (Pablo Martinez Monsivais/Associated Press)

Trump is upset that Sessions recused himself months ago from the investigation into interactions between Russian officials and the Trump campaign, and that Sessions has not taken a tougher line against Trump's defeated Democratic rival, Hillary Clinton.

Republican Sen. Lindsey Graham of South Carolina warned Thursday there would be "holy hell" to pay if Trump fired Sessions.

After meeting his Salvadoran counterpart, Sessions told AP he was "thrilled" with the support he's received, presumably from lawmakers.

"I believe we are running a great Department of Justice," he said.

"I believe with great confidence that I understand what is needed in the Department of Justice and what President Trump wants. I share his agenda."

Opportunity to chat

He acknowledged, with considerable understatement, "it hasn't been my best week … for my relationship with the president."

The two have not spoken recently, he said. "But I look forward to the opportunity to chat with him about it."

In Congress, Republican Sen. Ben Sasse of Nebraska went to the Senate floor Thursday to discourage Trump from making a so-called recess appointment while the Senate is away at the end of August — should that be the president's intention.

A recess appointment would allow Trump to appoint anyone of his choosing and bypass Senate confirmation until 2019 if the Senate recesses for 10 days or more in August.

"If you're thinking of making a recess appointment to push out the attorney general, forget about it," Sasse said. "The presidency isn't a bull, and this country isn't a china shop."

Stood his ground

The previous evening, the Republican chairman of the Senate Judiciary Committee, Iowa Sen. Chuck Grassley, tweeted that he wouldn't be holding a confirmation hearing for a new attorney general if Trump decided to go that route.

Although largely deferential to a president who seemed bent on tormenting him, Sessions stood his ground on his decision to recuse himself from the Russia investigation. He had bowed out of any involvement in that probe after acknowledged meeting with Russia's ambassador during the campaign.

"Knowing the integrity that's required of the attorney general, I believe I made the right decision," he told Fox News. He said his recusal was in keeping with the rule of law "and an attorney general who doesn't follow the law is not very effective in leading the Department of Justice."

The White House of late has appeared to be trying to tamp down the notion that Trump wants Sessions out — without offering a rousing endorsement of him, however.

"The president wants him to do his job, do it properly," the White House press secretary, Sarah Huckabee Sanders, said Thursday. "He wants him to be tough on the intelligence leaks and he wants him to move forward."

Anti-gang task force

In San Salvador, Sessions met his Salvadoran counterpart, Douglas Melendez, and congratulated him on charges outlined over the last two days involving strategy against more than 700 gang members, many of them from MS-13, said the Justice Department.

He also met members of an international anti-gang task force at an event where an FBI agent described MS-13 as a highly co-ordinated and well-organized gang whose imprisoned leaders order violence in the U.S. from their prisons in El Salvador.

MS-13 is an international criminal enterprise with tens of thousands of members in several Central American countries and many U.S. states. The gang originated in immigrant communities in Los Angeles in the 1980s then entrenched itself in Central America when its leaders were deported.

It's known for hacking and stabbing victims with machetes, drug dealing, prostitution and other rackets. Its recruits are middle- and high-school students predominantly in immigrant communities, and those who try to leave risk violent retribution, law enforcement officials have said.