Border Patrol agents used pepper spray and tear gas Sunday as about 500 migrants from Central America rushed the U.S.-Mexico border at Tijuana, prompting some criticism of the Trump administration for deploying tear gas.

Some denounced the response, although in 2013 the Border Patrol under the Obama administration deployed pepper spray, but not tear gas, on a much smaller group of migrants rushing the border.

“Anyone uncomfortable with spraying tear gas on children is welcome to join the coalition of the moral and the sane,” Sen. Brian Schatz, D-Hawaii, said on Twitter.

“Families are frightened and soldiers are shooting tear gas at toddlers … ,” Amnesty International tweeted.

“It is a despicable act on the part of the Trump administration and CBP [Customs and Border Protection] officials to attack defenseless women and children firing tear gas, a chemical agent, at them,” Angelica Salas, executive director of the Coalition for Humane Immigrant Rights, said in a prepared statement to Huffington Post.

Agents under the Obama administration used another chemical agent, pepper spray, to prevent about 100 migrants from crossing the border.

Homeland Security Secretary Kirstjen Nielsen was among those defending the agents’ actions Sunday, pointing out that they were being attacked by a mob of migrants.

“Today @CBP personnel were struck by projectiles thrown by caravan members. Such actions are dangerous & not consistent w peacefully seeking asylum. The perpetrators will be prosecuted. I will continue to aggressively support DHS personnel as they work to safely secure our border,” Nielsen wrote on Twitter.

“Some are asking why would the U.S. use tear gas. THIS IS WHY — To STOP an invasion,” tweeted Stephanie Hamill, a video columnist for The Daily Caller.

Border Patrol agents, after being attacked with rocks and bottles, used pepper spray in the 2013 incident to push back the 100 migrants who rushed the border in an attempt to enter San Diego.

In both incidents, migrants hurled hard objects at the Border Patrol, although the crowd was much bigger Sunday.

It is not clear whether women and children were among those hit with pepper spray in 2013, but media relayed images of women fleeing with children Sunday after agents used both tear gas and pepper spray.

The incident Sunday also included hundreds more migrants attempting to overrun the border and resulted in 42 arrests even as some migrants continued to try to cross the border, Rodney Scott, chief Border Patrol agent at San Diego, said on CNN.