As he was sworn into office in 2018, U.S. Attorney William M. McSwain maintained that he did not see his job as political.

And yet, throughout his three-year term as the top federal prosecutor in the region, politics has shadowed his every step.

From his frequent attacks on Philadelphia District Attorney Larry Krasner’s agenda to the impulse of critics to dismiss him as an acolyte of the man who appointed him, President Donald Trump, McSwain has had a tenure that coincided with a moment in which the Justice Department, the role of prosecutors, and the criminal justice system became a central focus of political debate.

He stepped down from his post Friday, making way for a successor whom President Joe Biden will appoint in the coming months. But despite the fractious times in which he served, McSwain, a 51-year-old West Chester Republican, insisted in an interview with The Inquirer that he still viewed his job — and his tenure in it — as entirely apolitical.

“Maybe I underestimated at the beginning of my tenure the desire of certain people to try to politicize law enforcement,” he said.

Asked about his next chapter, though, he wouldn’t rule out politics.

“I hope that there will be opportunities for me in the future to continue in public service,” he said. “I don’t think you’ve heard the last of me.”

Others in his party are eager to draft him. His name has consistently been floated as a possible GOP candidate for Congress or the governor’s office, or as a successor to retiring U.S. Sen. Pat Toomey. As McSwain announced his impending resignation earlier this month, Toomey, a fellow Republican, issued a statement describing him as an “indispensable” and “dedicated” public servant.

A former Marine platoon commander, Harvard grad, and a resident of a county that only recently flipped blue, McSwain has a background that could set him up well on a campaign trail. And as launching pads for political ambitions go, a stint as the U.S. attorney isn’t a bad place to start.

As the Justice Department’s chief representative in a nine-county region stretching north from Philadelphia to Allentown and west past Reading, the U.S. attorney sets priorities on high-profile cases and in eastern Pennsylvania oversees an office of 130 government lawyers prosecuting political corruption, drug trafficking, cybercrime, and terrorism, as well as handling civil matters on behalf of the federal government.

Chris Christie used the reputation he cultivated as New Jersey’s outspoken, hard-charging U.S. attorney to propel him into the governor’s mansion as a Republican in a traditionally blue state.

Pat Meehan — the last Republican to hold the job of U.S. attorney for eastern Pennsylvania before McSwain — went on to a multiterm congressional career, after leading the office for seven years under President George W. Bush.

McSwain had spent a few years as an assistant U.S. attorney and then a longer stretch in private practice at the former Drinker Biddle firm when Trump tapped him for the top prosecutor’s job. At the time he was a political neophyte.

Still, once in the post, he capitalized on the platform it provides to establish a public persona more than any recent predecessor.

“We have a big platform. We have a big bully pulpit,” he said. “We have the ability to accomplish a lot of good and it’s just a wasted opportunity if we just sort of hold back.”

As McSwain hosted frequent news conferences, sat for national TV interviews, and let his face appear on highway billboards to advertise office initiatives, his tenure was marked by nothing if not his outspokenness and the divisive reaction his words often provoked in a city led by Democrats whose criminal justice views often ran counter to his own.

He eagerly threw himself into the fray, delivering broadsides against what he describes as a “culture of lawlessness” fostered by Democratic leaders and challenging them in court on big political swings — from their support of supervised injection sites to their endorsement of Philadelphia as a sanctuary city for undocumented immigrants.

Reflecting back on his tenure, McSwain draws broad thematic links among many of the high-profile cases he shepherded, from his efforts against supervised injection sites, which he personally argued in court, to the corruption indictments his office secured against labor leader John “Johnny Doc” Dougherty and City Councilmembers Bobby Henon and Kenyatta Johnson.

He cast his office’s work under his watch as building a bulwark against chaotic forces threatening to undermine the rule of law and devastate Philadelphia. And the 53% rise in violent-crime prosecutions he oversaw — some of them taken over from Krasner, whose office McSwain said he did not trust to achieve a just outcome — is of a piece.

“There’s just this culture of lawlessness that I see in the city, that we wanted to be a bulwark against,” he said. “If somebody isn’t going to stand there and say they’re going to enforce the law and they’re not going to push back on some of these things, it really can lead to absurd results.”

Krasner — whose progressive approach to criminal justice McSwain blames for stoking near-record shooting and homicide rates — shrugged off such criticism and McSwain’s departure in recent statements, calling him not only wrong but a “Trumpian demagogue.” He said he looked forward to a reconfigured Justice Department under the Biden administration.

But McSwain’s harshest critics and his most ardent supporters can agree on one thing: He’s been nothing if not unwavering.

“I think I’ve been consistent,” he said. “Hopefully I’ve been principled. If you’re going to lead a law enforcement organization in this kind of divided, politically charged environment … you have to not care about the criticism.”

McSwain may still bristle at the suggestion that politics, whether of the moment or of his own making, played a role in defining his tenure. But he acknowledges as he leaves that he has developed a taste for what he calls “the scrum” — staking out a position, debating with those who disagree with him, and trying to move public opinion to his side.

“I didn’t realize how much I liked that before I was in this job,” he said. “That’s one of the reasons I’m encouraged by seeing what happens in the future.”

Whether it’s a return to life as a private citizen or a run for an elected post, he doesn’t sound like a man who is ready to leave those debates behind.

“The soul of the city is being battled over right now,” he said. “And I can think of no more important battle.”