WASHINGTON (AP) — Kevin McAleenan, a career civil servant who became the unlikely point man for President Donald Trump's hardline immigration policies, is stepping down as acting Homeland Security secretary after six months on the job.

McAleenan told The Associated Press he was leaving on his own terms — a contrast to other top administration officials pushed out during Trump's tenure. But his departure ends an awkward period of leadership — one in which McAleenan delighted Trump by getting border crossing numbers to fall yet remained an outsider in an administration where top figures — including in his own department — were brash Trump supporters popular on conservative media.

A White House official with knowledge of the decision confirmed that it was McAleenan's decision. The official wasn't authorized to speak publicly and spoke to AP on condition of anonymity. Trump tweeted that McAleenan was leaving to spend more time with his family and go to the private sector.

No replacement was yet named at the department, which has seen its ranks decimated through firings and resignations. The acting DHS deputy secretary is the head of the Transportation Security Administration.

And it creates yet another top-level vacancy in Trump's Cabinet — at the department responsible not only for immigration enforcement but also for helping states secure elections.

"We have worked well together with Border Crossings being Way down," Trump tweeted of McAleenan.

McAleenan tweeted that he had worked — with the president's support — to help stem the border crisis and that he would help ensure a smooth transition at DHS.

"I want to thank the President for the opportunity to serve the men and women of the Department of Homeland Security," McAleenan wrote.

House Speaker Nancy Pelosi called McAleenan's departure "the latest sign of this Administration's failed leadership, which has worsened the humanitarian situation at the border, and injected pain and tragedy into countless lives."

McAleenan took over in April after Secretary Kirstjen Nielsen quit. Trump said he'd name a replacement in the coming week, the fifth leader of DHS in two years.

The 240,000-person department is tasked with election security and cybersecurity, disaster response and even the Secret Service. But in Trump's world, Homeland Security means one thing: immigration. The president's signature issue makes the department his focus and his ire. Balancing a White House eager to push major changes with the reality on the ground is a constant challenge.

McAleenan, who has years of experience with border issues, was seen in Trump's circle as someone who could get control over the crisis, despite his stance as a moderate Democrat who pushed for aid to be restored to Central American nations.

He was among those behind the administration's widely maligned practice of separating families at the border last year, though McAleenan later said he regretted the policy because it lost the public trust.

He also expanded a program where asylum seekers are forced to wait their claims out in Mexico; more than 42,000 migrants have been subjected to it. And most recently, the administration made migrants ineligible for asylum if they crossed through a third country on their way to the U.S.

And he brokered major agreements with Central American countries on asylum and border security — something others were unable to do.

Alan Bersin, who worked closely with McAleenan in the Obama administration, said he did his job effectively in three administrations, Republican and Democrat, but was done in by a polarizing environment and lack of White House support.

"He did his best as a professional public servant but those qualities are not prized in this administration," said Bersin, an assistant Homeland Security secretary for international affairs and Customs and Border Protection commissioner under Obama.

Bersin credited McAleenan's close work with Mexico for helping lower border arrests from May peaks.

Earlier this spring, shortly before McAleenan took over, he stood in El Paso as U.S. Customs and Border Protection commissioner and warned that the border had reached a breaking point, with tens of thousands of Central American families crossing and border facilities unable to keep up.

It got worse — reports of children being held in squalid conditions for weeks at border facilities, young mothers with no medical care for their infants, and child deaths.

McAleenan went before Congress to ask for more than $1 billion in emergency funding that eventually passed and some of the pressures eased; the last month of the budget year saw major declines in crossings.

But his tenure at the helm of DHS was marked by internal squabbling and jockeying by others in his department vying for top jobs. The sparring is likely to continue as Trump decides who will lead the department now.

And he didn't always agree with White House-pushed policies. McAleenan, like others in the job before him, was opposed to an enforcement operation targeting families here illegally who were in the interior of the U.S., saying it was not worth the resource drain given the crisis at the border.

Trump, the head of Immigration and Customs Enforcement and others said it would be a show of force that could help deter people from coming in. Details of the operation were leaked to the media. Some, like former ICE director Tom Homan, seemed to point a finger at McAleenan during an appearance on Fox News. He later said he wasn't accusing him.

McAleenan weathered the storm, but Mark Morgan, acting head of CBP, and Ken Cuccinelli, acting head of U.S. Citizenship and Immigration Services, vocal supporters of Trump's immigration policies, have since then become the face and mouth of the department, while McAleenan took a public back seat.

Christopher Wilson, deputy director of the Wilson Center's Mexico Institute in Washington said people are questioning what McAleenan stands for, "questioning why he went along with the Trump administration and some of the things they did, but I believe he was a professional," he said.

"He attempted to do his job in a nonpartisan, nonpolitical way. That may not be possible. That may be why he's no longer there," he said.

___

Associated Press writers Zeke Miller in Washington and Elliot Spagat in San Diego contributed to this report.

Online Public Information File

Viewers with disabilities can get assistance accessing this station's FCC Public Inspection File by contacting the station with the information listed below. Questions or concerns relating to the accessibility of the FCC's online public file system should be directed to the FCC at 888-225-5322, 888-835-5322 (TTY), or fccinfo@fcc.gov.