The busiest port of entry along the southwest border was shut down by U.S. immigration officials this past weekend after hundreds of Central American migrants hoping to declare asylum attempted to cross fencing that separates Mexico and the U.S.

U.S. agents responded to the breach, as well as reports of rocks and bottles thrown by protesters at the border, by firing tear gas at the thousands of Central American migrants who had gathered near the San Ysidro border crossing in Tijuana, Mexico, for a demonstration.

Images showing families fleeing tear gas prompted outrage from some American lawmakers and advocates about the growing violence against migrants seeking asylum in the U.S.

The Department of Homeland Security said it was responding to “lawlessness.” And President Donald Trump urged Mexican officials to move the migrants away from the border.

Here’s a closer look at what’s happening at the border.

What happened

The number of Central American migrants seeking asylum from their home countries has been growing in Tijuana. Since the first members of the caravan arrived a couple weeks ago, the group amassed in the border city has grown to about 5,000 people.

This is the same group — made up of migrants who originally started their journey together in Honduras — that Trump characterized as an “invasion” ahead of the U.S. 2018 midterm elections. Having traveled northward toward the border for weeks, the caravan has grown increasingly frustrated with long wait times for their asylum claims since arriving in Tijuana. The waiting list for asylum claims had 3,000 names on it before the caravan arrived, the Associated Press reported, adding the San Ysidro center is processing fewer than 100 claims a day.

Francisco Vega, the governor of the state where Tijuana is located, said the number was even higher — nearly 9,000 — when factoring in the migrants’ presence across Baja California. Vega called the situation an “issue of national security” and urged the Mexican government to intervene and provide additional assistance.

On Sunday, there was a planned, peaceful demonstration outside the San Ysidro port of entry to protest the wait times. Anticipating the protest, U.S. immigration officials said they deployed additional resources to the area.

The protest gradually moved toward a pedestrian crossing at the port. There, the situation escalated as hundreds of protesters clashed with Mexican police equipped with riot gear and some migrants attempted to cross in different spots along the border, according to U.S. Customs and Border Protection. Some U.S. personnel were struck by various projectiles hurled by migrants.

Things heated up a little when people ran past the federales and small clash. A federal police officer has a cut on lip from the scuffle. This is raw video and there may be cuss words pic.twitter.com/Tg0SXyPaFd — WendyFry (@WendyFry_) November 25, 2018

That’s when U.S. immigration agents fired tear gas on the migrants, according to government officials. They also closed all vehicle and foot traffic through the port, which receives tens of thousands of vehicles and pedestrians moving northward each day.

The closing lasted almost six hours.

Defending the U.S.’s response, Homeland Security Secretary Kirstjen Nielsen said in a statement Sunday that the port of entry was closed “to ensure public safety in response to large numbers of migrants seeking to enter the U.S. illegally.”

Nielsen said some migrants, after being prevented from entering the port of entry, attempted to breach border infrastructure and “sought to harm CBP personnel by throwing projectiles at them.”

“[The Department of Homeland Security] will not tolerate this type of lawlessness and will not hesitate to shut down ports of entry for security and public safety reasons,” she added.

In a Facebook post late Monday, Nielsen doubled down on her defense of the tear gas deployment, adding that U.S. immigration officials “responded admirably and responsibly to the events on Sunday. It is a testament to their training and professionalism that no one was injured.”

Later Monday, Mexico’s foreign ministry released a statement that questioned the U.S.’ use of tear gas at the border, calling for an investigation into what the country described as non-lethal weapons directed toward Mexico.

How big was the protest?

The federal government has suggested that it responded to “large numbers of migrants” looking to enter the U.S. illegally.

This statement requires an asterisk. Thousands of Central American migrants have indeed taken shelter at the Benito Juarez Sports Complex in Tijuana, which has been largely housing this group. Despite the clash on Sunday, most of the migrants gathered for the protest peacefully.

The city made the complex open to migrants earlier this month, anticipating the growing number arriving near the border. Last week, the complex reached capacity, despite more continuing to showing up, The Arizona Republic reported.

After Sunday’s clash, nearly 100 people have been arrested in attempting to cross the border illegally. Mexico’s National Migration Institute said it planned to deport those who tried to “violently” enter the U.S. A CBP spokesperson told reporters Monday that U.S. officials arrested 69 people who tried to enter the U.S. illegally. The official total counts of those who attempted to breach the border differ between the countries; Mexico places that number at 500, the U.S. at 1,000.

Can the U.S. legally prevent migrants from seeking asylum?

On Nov. 9, Trump issued new regulations that sought to make it harder for migrants to make asylum claims at the border. The president, invoking national security powers, signed a proclamation that denied asylum to migrants who illegally entered the U.S. border between ports of entry. Those who entered through official ports of entry would still be allowed to proceed with their asylum claims.

The American Civil Liberties Union, among other groups, made a near immediate challenge in the courts, suing the federal government to block the rule changes. U.S. District Judge Jon S. Tiger in San Francisco temporarily suspended the new policy for 30 days.

“Whatever the scope of the President’s authority, he may not rewrite the immigration laws to impose a condition that Congress has expressly forbidden,” Tiger wrote in his ruling.

Nielsen said an appeal would be filed in the case.

There are longstanding U.S. immigration laws that allow people fleeing persecution a chance at asylum, no matter if they don’t enter through an official port of entry.

The Trump administration has also pushed the idea that Mexico should allow asylum-seekers to remain on that side of the border fence while their claims were being processed in the U.S. The president doesn’t have the legal authority to pursue that proposition, according to Jami Floyd, a legal analyst for WNYC.

“The asylum laws have been made by Congress, and Congress has the authority to either change those laws or leave them in place,” she told PBS NewsHour Weekend.

“And the president cannot act unilaterally to change those laws. So, no, whatever he may tweet, whatever he may think, he cannot act unilaterally to even work with the government of Mexico,” Floyd added.

How did Trump react?

In a tweet on Monday, Trump called the migrants “stone cold criminals” and said Mexico should move the migrants back to their home countries.

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. We will close the Border permanently if need be. Congress, fund the WALL! — Donald J. Trump (@realDonaldTrump) November 26, 2018

“Do it by plane, do it by bus, do it anyway you want, but they are NOT coming into the U.S.A. We will close the Border permanently if need be. Congress, fund the WALL!” he added.

The president further defended the U.S. response outside the White House later Monday, saying U.S. officials had to deploy tear gas because they were “being rushed by some very tough people.”

“Nobody’s coming into our country unless they come in legally,” Trump told reporters.

What the latest incident means for Mexico

Local Mexican officials have warned they’re unable to adequately accommodate the group of migrants. Tijuana Mayor Juan Manuel Gastelum declared a humanitarian crisis for the city a day before Sunday’s protest. He added that the city couldn’t adequately devote Tijuana’s public resources to providing the migrants “a decent space.”

Since the incident, Mexico said it will increase security forces in the area, telling migrants in and around the sports complex that they couldn’t approach the border area.

Mexico’s response to the migrant impasse may change when its leadership changes this week. Mexican President-elect Andres Manuel López Obrador (known as AMLO) takes office on the first day of December. There was a Washington Post report over the weekend that said the incoming Mexican government had agreed with the Trump administration to allow asylum-seekers to wait out their claims while staying in Mexico. That way, migrants remain below the border while their claims are being processed in the U.S.

However, the new Mexican government denied that any deal had taken place. Incoming Interior Minister Olga Sanchez said in a statement that there is “no agreement of any sort between the incoming Mexican government and the U.S. government.”

What’s next for the migrants?

Some migrants sounded dejected about their chances at asylum after Sunday’s incident.

Cindy Martinez of El Salvador told AP that the tear gas was deployed before she was about to cross barbed wire at the border.

“I see it as impossible for [the U.S.] to want to give us asylum,” Martinez said. “Because of the words that President Donald Trump has said, I think this is impossible.”

Another migrant, Maria Edwina Perez, and her 3-year-old son have been staying inside the sports complex with the thousands of other migrants in Tijuana. She told KPBS that she’s been praying to God in the hopes that Trump allows them into the U.S.

“If he doesn’t want the men to enter, he should let the women enter. We come to work, not to create disorder,” Perez said, adding that she is “a peaceful woman with patience.”

Meanwhile, there haven’t been sufficient supplies for people at the shelters, she said. Perez told KPBS that another mother gave her a pair of shoes that she could sell for some food for her son.

We followed Honduran Karla Cruz from southern Mexico to the U.S. border as she traveled with a caravan of migrants. She hoped to escape violence at home and make it to Texas, where her mother fled 15 years ago. But thousands of miles later, Cruz and her companions faced a closed border and the potential end of a dream. Producer Julia Galiano-Rios and correspondent Nick Schifrin report.