U.S. Homeland Security Secretary Kirstjen Nielsen on Monday defended the use of tear gas fired by U.S. Border Patrol agents at a group of migrants who tried to illegally cross a border fence.

The migrants reportedly threw rocks at U.S. agents and stormed a fence Sunday at the crossing near Tijuana, following a protest calling for the right to asylum.

Nielsen said the gas was fired to disperse the migrants and that U.S. would not tolerate “lawlessness.” The incident, which left migrant families with children scrambling to escape the toxin, was condemned by Democrats and activists.

DNC chairman Tom Perez tweeted: “Shooting tear gas at children is not who we are as Americans.”

Gavin Newsom, the incoming Democratic governor of California, posted: "These children are barefoot. In diapers. Choking on tear gas. That’s not my America. We’re a land of refuge. Of hope. Of freedom."

Mexico’s interior ministry said it would deport to their home countries any migrants it identified as having attempted to “violently” and “illegally” cross the border. Tijuana police had arrested 39 people by Sunday night, the agency said.

What happened Sunday?

The standoff began with a peaceful protest by hundreds of migrants that started at Tijuana’s Benito Juárez Sports Complex, where most of the thousands of Central American migrants seeking to enter the U.S. have been sheltered in recent weeks. Chanting “We aren't criminals! We are hard workers,” they marched toward the border, calling for the right to asylum in the United States.

The marchers were blocked by Mexican police equipped with shields and riot gear to stop them approaching the San Ysidro port of entry. As frustrations grew, groups broke through the police cordon and tried to rush the fence on either side of the official crossing.

U.S. soldiers and U.S. border patrols fire tear gas towards migrants from the U.S.side of the border fence between Mexico and the United States in Tijuana, Mexico, November 25, 2018. (REUTERS/Kim Kyung-Hoon)

Mexico’s Interior Ministry said hundreds tried to cross the border in a “violent manner.”

Amid the unrest, the San Ysidro port of entry was closed for several hours, “to ensure public safety in response to large numbers of migrants seeking to enter the U.S. illegally,” Nielsen said. The border, the busiest crossing between the countries, normally has tens of thousands of crossings per day.

Migrants return to Mexico after being hit by teargas by U.S. Customs and Border Protection after attempting to illegally cross the border wall into the United States in Tijuana, Mexico November 25, 2018. (REUTERS/Adrees Latif)

Why was the tear gas fired?

Several hundred migrants managed to breach the first fence, and were fired on with tear gas as they attempted to cross a second barrier, according to AFP.

U.S. officials said the migrants threw rocks that struck several agents, and were fired on due to the risk they posed.

Footage from the scene showed people running and screaming to flee the cloud of tear gas, including families with young children. One woman collapsed unconscious amid the melee, and two babies were seen affected by the gas, Reuters reported.

Nielsen said the Department of Homeland Security would “not tolerate this type of lawlessness and will not hesitate to shut down ports of entry for security and public safety reasons.”

“We will also seek to prosecute to the fullest extent of the law anyone who destroys federal property, endangers our front-line operators, or violates our nation's sovereignty,” she said.

Migrants run from tear gas released by U.S border patrol, near the border fence between Mexico and the United States in Tijuana, Mexico, November 25, 2018. (REUTERS/Hannah McKay)

What will happen to the migrants?

Mexican authorities issued a warning in response to the unrest, the first time since the arrival of the migrant caravan in Tijuana that a large group has gathered at the border fence.

Mexican Interior Minister Alfonso Navarrete described the events as acts of provocation, that, “far from helping their objectives,” could have led to a serious incident. Tijuana’s Mayor, Juan Manuel Gastélum Buenrostro, tweeted that he was determined not to allow the migrants’ actions to affect his city’s crucial ties with the United States.

The migrants have faced protests against their presence in Tijuana since their recent arrival following a 4,000km (2,500 miles) from the Central American countries of Honduras, Guatemala and El Salvador, where they say they face endemic gang violence and poverty.

But they could face an even longer wait in the Mexican border city due to a new Trump administration policy to ban would-be migrants from entering the United States until their asylum claims are completed — a process that could take months.

A migrant girl from Honduras cries after running away from tear gas thrown by the U.S. border control near the border wall between the U.S. and Mexico in Tijuana, Mexico November 25, 2018. (REUTERS/Kim Kyung-Hoon)

The policy has left many of the desperate migrants in an intolerable situation. “They want us to wait in Mexico but I for one am desperate. My little girl is sick and I don’t even have money for milk,” a 32-year-old Honduran name Joseph Garcia told Reuters. “I can’t stand it anymore.”

Trump — who has taken a hardline approach to security at the southern border, deploying thousands of troops who he says are authorized to use lethal force — tweeted Monday that Mexico should deport the migrants and repeated his threat to “close the Border permanently if need be.”

“Mexico should move the flag waving Migrants, many of whom are stone cold criminals, back to their countries. Do it by plane, do it by bus, do it anyway you want, but they are NOT coming into the U.S.A,” he posted.

Trump earlier tweeted that Mexico should turn back the caravans before they reach the U.S. border, and reiterated his belief that the caravans were a way for Central American countries to “dump” undesirables in the U.S. Thousands more migrants are expected to join the estimated 5,000 already in Tijuana in coming days, as more caravans reach the border.

The Honduran government condemned the use of force against the migrants and repeated its call for U.N. assistance to the asylum seekers at the border.