Facing an avalanche of outrage, President Trump on Wednesday signed an executive order to stop more migrant children from being separated from their parents at the southern border.

“We’re signing an executive order. I consider it to be a very important executive order. It’s about keeping families together, while at the same time being sure we have a very powerful, very strong border and border security will be equal, if not greater than previously,” the president said as he signed the order in the Oval Office, flanked by Vice President Mike Pence and Homeland Security Secretary Kirstjen Nielsen.

“So we’re going to have strong, very strong borders, but we’re going to keep the families together,” he added. “I think the word ‘compassion’ comes into it, but it’s still equally as tough if not tougher.”

It was unclear what would happen to the 2,300 kids already taken from their families.

“It is still very early and we are awaiting further guidance on the matter,” a spokesman for the Administration for Children and Families, a division of Health and Human Services, told The Post.

“Reunification is always the ultimate goal of those entrusted with the care of unaccompanied minors, and the administration is working towards that.”

Trump, who until Wednesday had defiantly refused to change his policy, admitted that photos of kids taken from their parents and placed in detention centers — which sparked a firestorm of criticism — played a role in his abrupt about-face.

“I didn’t like the sight or the feeling of families being separated,” he said at the signing, echoing earlier comments at a meeting with GOP lawmakers.

“Those images affect everybody. But I have to say, you have double standards. You have people that want absolute security and safety, and you have people that do look at the children and then you have people like me, and I think most of the people in this room, they want both,” he said.

The order instructs Attorney General Jeff Sessions to petition the federal court in California to modify a settlement agreement in a 1997 immigration case known as Flores vs. Reno, which limited how long ­migrant children can be detained.

The administration wants to extend the current 20-day limit so that the kids can ­remain with their parents, even in detention facilities.

Gene Hamilton, counselor to Sessions, could provide no specifics during a conference call with reporters about how or when the order would be implemented.

The president’s order says families will be detained to the “extent permitted by law and subject to the availability of appropriations” — meaning Trump’s order is a stopgap measure dependent on the Flores decision being changed or overturned. Officials said it was not clear whether families would again be separated after 20 days if the administration loses its court appeal.

An official told The Washington Post the Trump administration was anticipating lawsuits and preparing to litigate Flores in court, especially if lawmakers fail to pass a more sweeping immigration bill.

Trump repeatedly stressed that he was not backing away from his hard-line “zero tolerance” stance on illegal immigration.

“We’re keeping families together and this will solve that problem. At the same we are keeping a very powerful border and it continues to be zero tolerance. We have zero tolerance for people that enter our countries illegally,” the president said.

First Daughter Ivanka Trump — who had taken heat for not publicly commenting on her father’s divisive policy — took to Twitter Wednesday to praise him.

“Thank you @POTUS for taking critical action ending family separation at our border. Congress must now act + find a lasting solution that is consistent with our shared values; the same values that so many come here seeking as they endeavor to create a better life for their families,” she wrote.

The president’s stunning about-face came after a week during which he repeatedly insisted that only Congress could put an end to the separation policy.

“We can’t do it through an executive order,” he insisted last Friday.

Sessions, who enacted Trump’s zero-tolerance policy early last month and used the Bible to justify the separations, also changed his tune. “We do not want to separate parents from their children. What we want is a safe, lawful system of immigration that would end this question altogether,” he said in a statement.

The president, in his remarks to lawmakers, seemed ambivalent about changing course.

“The dilemma is that if you’re weak, as some people would like you to be, if you’re really, really, pathetically weak, the country’s going to be overrun with millions of people, and if you’re strong, then you don’t have any heart. That’s a tough dilemma. Perhaps I’d rather be strong but that’s a tough dilemma,” he said.

Trump also canceled Thursday’s annual congressional picnic, saying lawmakers were too busy to take an afternoon off.

The House is expected to vote on a pair of bills Thursday — which Trump said he would sign — that would also extend the period immigrant children can be held after they cross the border illegally with their parents.

Trump has been under steadily mounting bipartisan pressure to reverse course on his policy, which has left migrant children housed in an empty big box store in Texas and other shelters, including in New York.

Ex-President Barack Obama, UK Prime Minister Theresa May and Canadian PM Justin Trudeau all slammed the policy, as did Pope Francis and other religious leaders.