Initially, Mr. Trump offered the civil division job to George T. Conway III, a well-known litigator and the husband of the presidential counselor Kellyanne Conway, but he turned it down.

Mr. Hunt’s trajectory also suggests that the administration has found civil servants to elevate to the highest echelons of government, despite Mr. Trump’s assertion that the government is controlled by a so-called “deep state” that is out to get him.

Mr. Hunt’s nearly 20-year tenure at the Justice Department foreshadowed him taking on this highly political role atop the civil division, where he will defend the president and his policies, a review of court records and interviews with 10 of his current and former colleagues shows.

On numerous occasions during the Obama administration, Mr. Hunt challenged his political bosses, the colleagues said, and at one point removed his name from a contentious legal brief just hours before it was set to be filed, irking some of them. When pushing back against Obama-era policies, he would repeat a favorite phrase: “This is not how Ashcroft would have done it,” referring to John Ashcroft, President George W. Bush’s first attorney general.

The Justice Department declined to make Mr. Hunt available for an interview.

Once Mr. Sessions was sworn in as Mr. Trump’s attorney general, he selected Mr. Hunt as his chief of staff, a role that gave him a front-row seat to the early days of the Russia investigation and the firing of Mr. Comey. Mr. Hunt personally drafted Mr. Sessions’s recusal from the investigation — that recusal is now a flash point with the president — and witnessed a now-famous meeting in which Mr. Comey complained to Mr. Sessions about being forced into private discussions with Mr. Trump.

“Mr. Hunt was the Attorney General’s top aide on some of his most controversial actions in 2017, from his recommendation to fire James Comey, to ending the DACA program, and the DOJ’s defense of Trump’s travel bans,” Senator Richard J. Durbin, the No. 2 Senate Democrat, said in a statement explaining his opposition to Mr. Hunt.

The nomination of Mr. Hunt, known as Jody, comes as personal politics have become an issue for the Justice Department. Mr. Trump has assailed senior officials involved in the Russia investigation for ties to Democrats, a line of attack that was once unthinkable in a department where it is understood that career professionals can hold political beliefs without impairing their judgment.