Immigration agents in Hayward detained two undocumented men with alleged criminal backgrounds just weeks after the city formally declared itself a sanctuary city.

The incident has left families and the community on edge.

Hayward city leaders said regardless of someone's background, it is important that all residents receive due process of the law. But critics said the undocumented immigrants broke the law to begin with and they should have been deported a long time ago.

Lourdes Olvera is left taking care of her two young grandchildren while their mother is away fighting to keep their father, Antonio Valenzuela, in the United States.

Olvera said Valenzuela was on his way to work last Thursday with his friend, Jose Salgado, when they were detained by Immigration Customs Enforcement agents. The agents were in the area looking for a suspect in an unrelated case.

Olvera said Valenzuela called her and said "take care of the children because immigration just got me."

Olvera said she feels bad for her grandson because he is especially close to his dad.

ICE tells NBC Bay Area neither man had ever been lawfully admitted to the United States. They said their database shows Valenzuela has been repatriated to his native Mexico three times and he previously served time for a DUI.

The second man, Salgado, has a previous felony charge for lewd acts with a minor.

Mayor Barbara Halliday, who successfully fought to declare Hayward a sanctuary city last month, is concerned.

"I just want to make sure that whatever the reasons they were taken away from their families their rights are protected," Halliday said.

But Juan Hernandez, a log cabin Republican, said the men lost their rights when they came into the country illegally.

"They're breaking the law. They should already be sent back, especially if they're criminals," Hernandez said.

ICE said both Valenzuela and Salgado will remain in their custody while the cases are reviewed.