A woman who has a child with accused bomber Ahmad Khan Rahami won an order late Tuesday from a New Jersey judge giving her sole legal and physical custody of the child and prohibiting Rahami from contacting the child until a Sept. 27 hearing.

Maria Mena’s claim that Rahami’s apparent involvement in terrorism and attempted murder of police officers could cause harm to the child that “is both emergent and irreparable,” according to the order by Superior Court Judge Peter Barnes III.

Rahami, 28, a U.S. citizen born in Afghanistan, remains in a Newark hospital after he was captured Monday after a shootout with police in Linden, New Jersey.

The New Brunswick judge, however, denied Mena’s request to change the child’s last name, but permitted her to renew the request later after presenting evidence.

advertisement | advertise on newsday

Barnes also denied Mena’s request to order counseling for the child and to prohibit news reporters from contacting the child, noting he had no authority to do either.

“However, the court recommends that the plaintiff obtain counseling services for the . . . child on her own,” Barnes wrote in his order.

Wednesday morning, four people, escorted by two officers, came to the quiet Edison home where Mena lives and spoke to someone through the window. They assured the person they were not media and spoke in Spanish, leaving shortly after.

With Alison Fox