Updated

Images and videos posted on social media Sunday afternoon showed hundreds of migrants from the leading Central American caravan pushing past Mexican riot police and rushing the border at the port of entry in San Ysidro, Calif., in a major test for both U.S. border authorities and Mexican officials.

U.S. Customs and Border Protection (CBP) said it suspended northbound and southbound crossings for both pedestrians and vehicles at the San Ysidro port of entry at approximately 11:30 a.m. local time. It later tweeted that the pedestrian crossings had re-opened, a little more than four hours after the initial closure. The vehicle lanes re-opened at approximately 5 p.m. local time, five-and-a-half hours after they were closed.

CBP added that some demonstrators "attempted to illegally enter the U.S. through both the northbound and southbound vehicle lanes at the port of entry itself. Those persons were stopped and turned back to Mexico."

U.S. border agents shot several rounds of tear gas after some migrants attempted to penetrate various points along the border and threw what appeared to be rocks at U.S. authorities.

Mexico's Milenio TV showed images of migrants climbing over fences and peeling back metal sheeting to enter. Tear gas fumes were carried by the wind toward people who were hundreds of feet away, including some children.

Honduran Ana Zuniga, 23, also said she saw migrants opening a small hole in concertina wire at a gap on the Mexican side of a levee, at which point U.S. agents fired tear gas at them.

Homeland Security Secretary Kirstjen Nielsen said in a statement that some migrants "attempted to breach legacy fence infrastructure along the border and sought to harm CBP personnel by throwing projectiles at them.

"As I have continually stated, DHS will not tolerate this type of lawlessness and will not hesitate to shut down ports of entry for security and public safety reasons," Nielsen said. "We will also seek to prosecute to the fullest extent of the law anyone who destroys federal property, endangers our frontline operators, or violates our nation’s sovereignty."

A migrant family, part of a caravan of thousands traveling from Central America en route to the United States, run away from tear gas in front of the border wall between the U.S and Mexico in Tijuana, Mexico November 25, 2018. REUTERS/Kim Kyung-Hoon - RC1CEA31D520

A migrant family, part of a caravan of thousands traveling from Central America en route to the United States, run away from tear gas in front of the border wall between the U.S and Mexico in Tijuana, Mexico November 25, 2018. REUTERS/Kim Kyung-Hoon - RC1CEA31D520

The Mexican Interior Ministry said Sunday afternoon it would immediately deport the migrants who tried to "violently" breach the border. The Mexican government described Sunday's events as "acts of provocation" that were "far from helpful" for the migrants' objectives.

Earlier this month, President Trump said that troops stationed at the border would treat thrown rocks like "firearms."

"We're not going to put up with that," the president said. "They want to throw rocks at our military, our military fights back. I told them to consider it a rifle. When they throw rocks, like they did at the Mexico military and police, I said, consider it a rifle."

The situation Sunday was not unprecedented. In 2013, during the Obama administration, Border Patrol agents used pepper spray to fend off a crowd of approximately 100 migrants who attempted to rush the San Ysidro port of entry. The migrants in that episode also reportedly threw rocks and bottles at U.S. authorities.

Within an hour on Sunday, the group from the caravan that rushed toward the border largely dispersed. Most of the migrants in the group were men.

Fox News had confirmed early Sunday through an organizer for Pueblo Sin Fronteras, the group helping organize the leading Central American migrant caravan, that members of the caravan were planning to attempt to cross the port of entry at San Ysidro later in the day.

Footage posted by ITV correspondent Emma Murphy also showed several U.S. Border Patrol helicopters reportedly flying low overhead on the Mexican side of the border.

In anticipation of the planned migrant effort, U.S. authorities said they had deployed additional personnel to the San Ysidro port of entry on Sunday, including Air and Marine agents.

Other video showed migrants pushing toward a border fence chanting, "Yes we can."

The dramatic escalation at the border came as Mexico's incoming government denied reports Saturday that it had struck a deal with the White House to keep asylum-seekers in the country while their claims move through U.S. immigration courts. President Trump, for his part, again threatened to close the entire southern border if no deal could be reached between the two counties.

Migrants cross a riverbed at the Mexico-U.S. border after getting past a line of police at the Chaparral border crossing in Tijuana, Mexico, Sunday, Nov. 25, 2018, as they try to reach the U.S. The mayor of Tijuana has declared a humanitarian crisis in his border city and says that he has asked the United Nations for aid to deal with the approximately 5,000 Central American migrants who have arrived in the city. (AP Photo/Ramon Espinosa)

Migrants cross a riverbed at the Mexico-U.S. border after getting past a line of police at the Chaparral border crossing in Tijuana, Mexico, Sunday, Nov. 25, 2018, as they try to reach the U.S. The mayor of Tijuana has declared a humanitarian crisis in his border city and says that he has asked the United Nations for aid to deal with the approximately 5,000 Central American migrants who have arrived in the city. (AP Photo/Ramon Espinosa)

On Saturday, the first episode of caravan-related violence directed at U.S. authorities was reported by U.S. Border Patrol in Arizona, as a 31-year-old Honduran man who apparently split off from the caravan threw rocks at agents and a helicopter after setting a tree on fire.

WATCH: TRUMP SUGGESTS MILITARY WILL OPEN FIRE IF CARAVAN MEMBERS THROW ROCKS AT US TROOPS, BORDER PATROL

The prospective deal between the U.S. and Mexico was seen as a way to dissuade thousands of Central American migrants from seeking asylum in the U.S., a process that can take years. The legal bar for claiming asylum is high and generally requires applicants to show a specific risk of persecution based on factors such as race, nationality, politics or religion.

Migrants break past a line of police as they run toward the Chaparral border crossing in Tijuana, Mexico, Sunday, Nov. 25, 2018, near the San Ysidro entry point into the U.S. More than 5,000 migrants are camped in and around a sports complex in Tijuana after making their way through Mexico in recent weeks via caravan. (AP Photo/Ramon Espinosa)

Migrants break past a line of police as they run toward the Chaparral border crossing in Tijuana, Mexico, Sunday, Nov. 25, 2018, near the San Ysidro entry point into the U.S. More than 5,000 migrants are camped in and around a sports complex in Tijuana after making their way through Mexico in recent weeks via caravan. (AP Photo/Ramon Espinosa)

Trump administration officials have characterized the vast majority of asylum claims as fraudulent or legally insufficient, and have taken steps to reduce the backlog of asylum claims that they say are often used by migrants to gain entry into the U.S. and disappear into the country as their claims are adjudicated.

A migrant man pushes a child in a baby stroller past a cordon of riot police as he joins a small group of migrants trying to cross the border together at the Chaparral border crossing in Tijuana, Mexico, Thursday, Nov. 22, 2018. A small group of Central American migrants marched peacefully to a border crossing in Tijuana Thursday to demand better conditions and push to enter the U.S. (AP Photo/Ramon Espinosa)

A migrant man pushes a child in a baby stroller past a cordon of riot police as he joins a small group of migrants trying to cross the border together at the Chaparral border crossing in Tijuana, Mexico, Thursday, Nov. 22, 2018. A small group of Central American migrants marched peacefully to a border crossing in Tijuana Thursday to demand better conditions and push to enter the U.S. (AP Photo/Ramon Espinosa)

TRUMP SLAMS 'DISGRACEFUL' NINTH CIRCUIT AFTER ASYLUM RULING, CALLS IT RUBBER-STAMP FOR HIS FOES

"There is no agreement of any sort between the incoming Mexican government and the U.S. government," future Interior Minister Olga Sanchez said in a statement.

Hours earlier, The Washington Post quoted her as saying that the incoming administration of Andres Manuel Lopez Obrador had agreed to allow migrants to stay in Mexico as a "short-term solution" while the U.S. considered their applications for asylum. Lopez Obrador will take office on Dec. 1.

Migrants wave at U.S. border control helicopters flying near the Benito Juarez Sports Center serving as a temporary shelter for Central American migrants, in Tijuana, Mexico, Saturday, Nov. 24, 2018. The mayor of Tijuana has declared a humanitarian crisis in his border city and says that he has asked the United Nations for aid to deal with the approximately 5,000 Central American migrants who have arrived in the city. (AP Photo/Ramon Espinosa)

Migrants wave at U.S. border control helicopters flying near the Benito Juarez Sports Center serving as a temporary shelter for Central American migrants, in Tijuana, Mexico, Saturday, Nov. 24, 2018. The mayor of Tijuana has declared a humanitarian crisis in his border city and says that he has asked the United Nations for aid to deal with the approximately 5,000 Central American migrants who have arrived in the city. (AP Photo/Ramon Espinosa)

The Washington Post reported Saturday that the Trump administration has won support from the Mexican president-elect's team for a plan dubbed "Remain in Mexico."

Migrants walk up a riverbank at the Mexico-U.S. border after getting past a line of Mexican police at the Chaparral border crossing in Tijuana, Mexico, Sunday, Nov. 25, 2018, as they try to reach the U.S. The mayor of Tijuana has declared a humanitarian crisis in his border city and says that he has asked the United Nations for aid to deal with the approximately 5,000 Central American migrants who have arrived in the city. (AP Photo/Ramon Espinosa)

Migrants walk up a riverbank at the Mexico-U.S. border after getting past a line of Mexican police at the Chaparral border crossing in Tijuana, Mexico, Sunday, Nov. 25, 2018, as they try to reach the U.S. The mayor of Tijuana has declared a humanitarian crisis in his border city and says that he has asked the United Nations for aid to deal with the approximately 5,000 Central American migrants who have arrived in the city. (AP Photo/Ramon Espinosa)

The newspaper also quoted Sanchez as saying: "For now, we have agreed to this policy of Remain in Mexico."  Sanchez did not explain in the statement why The Washington Post had quoted her as saying there had been an agreement.

TRUMP ADMIN SHARPLY LIMITS ASYLUM CLAIMS, CITING WIDESPREAD FRAUD, FEDERAL LAW

Early Sunday, Trump wrote on Twitter that it would be "very SMART" for Mexico to "stop the Caravans long before they get to our Southern Border" to avoid future logistics challenges at the border.

There were signs last week that the Mexican government has received that message. Mexican immigration agents on Wednesday detained almost all of the Central American migrants on a fourth caravan that recently entered Mexico seeking to reach the U.S., with Mexico's National Immigration Institute saying 213 migrants were detained and taken to a processing center. Those found to lack proper documents may face repatriation to their home countries.

Other administration officials sounded notes of optimism despite the apparent confusion on how to handle the migrants.

WATCH: SAN DIEGO BORDER PATROL DIRECTOR SAYS HE'S 'PREPARING FOR THE WORST'

"President Trump has developed a strong relationship with the incoming [Lopez] Obrador administration, and we look forward to working with them on a wide range of issues," White House spokesman Hogan Gidley said over the weekend.

Approximately 5,000 Central American migrants have arrived in recent days to Tijuana, just south of California, after making their way through Mexico via caravan. But agents at the San Diego port of entry process fewer than 100 claims per day.

Seven-year-old Honduran migrant Genesis Belen Mejia Flores waves an American flag at U.S. border control helicopters flying overhead near the Benito Juarez Sports Center serving as a temporary shelter for Central American migrants, in Tijuana, Mexico, Saturday, Nov. 24, 2018. The mayor of Tijuana has declared a humanitarian crisis in his border city and says that he has asked the United Nations for aid to deal with the approximately 5,000 Central American migrants who have arrived in the city. (AP Photo/Rodrigo Abd)

Seven-year-old Honduran migrant Genesis Belen Mejia Flores waves an American flag at U.S. border control helicopters flying overhead near the Benito Juarez Sports Center serving as a temporary shelter for Central American migrants, in Tijuana, Mexico, Saturday, Nov. 24, 2018. The mayor of Tijuana has declared a humanitarian crisis in his border city and says that he has asked the United Nations for aid to deal with the approximately 5,000 Central American migrants who have arrived in the city. (AP Photo/Rodrigo Abd)

On Friday, the mayor of Tijuana declared a humanitarian crisis in his border city of 1.6 million people,  saying he was asking the United Nations for aid to deal with the approximately 5,000 Central American migrants, most of whom were camped out inside a sports complex.

The comments by Mayor Juan Manuel Gastelum came as city officials and volunteers worked together to assist the 4,976 men, women and children who had arrived after more than a month on the road.

Hundreds of Tijuana residents have protested their arrival, complaining that recent caravans forced their way into Mexico from Guatemala.

Trump threatened Thursday, and again on Saturday, to shut down the border crossing entirely if his administration determines that Mexico has lost "control" of the situation in Tijuana.

Stephanie Leutert, director of the Mexico Security Initiative at the University of Texas at Austin, described the Remain in Mexico plan as a strategy to take away the ability of migrants to live and work in the U.S. while cases are processed.

"The hope is that asylum seekers will not want to live in [Mexico] for months/years and won't come," Leutert wrote on Twitter.

She added: "The big question is why would Mexico agree to this? ... Mexico has its own migratory enforcement interests and the various caravans have been a huge headache."

U.S. officials have said for months that they were working with Mexico on possible proposals. One variation, called "Safe Third," would have denied asylum claims on the grounds that asylum seekers had found haven in Mexico. President Enrique Pena Nieto offered thousands of Central Americans asylum on Oct. 26 if they agreed to remain in southern Mexico. Close to 3,000 migrants took Mexico up on the offer.

Sanchez said Saturday that the next government does not plan for Mexico to become a "Safe Third" country.

Julieta Vences, a congresswoman with Lopez Obrador's Morena party who is also president of Mexico's congressional migrant affairs commission, told the AP that incoming Foreign Minister Marcelo Ebrard has been discussing with U.S. officials how to handle a deluge of asylum claims at the border.

"They're going to have to open the borders (for the migrants) to put in the request," Vences said. "They will also give us dates, on what terms they will receive the (asylum) requests and in the case that they are not beneficiaries of this status, they will have to return here," Vences said.

She said Mexico needs to examine how to accommodate the migrants without angering locals.

"When they come back, we need to see how ... we can integrate them into an economic activity so that they can develop and not generate conflict with our own communities."

Local churches and charities have been feeding the migrants, with assistance from state and federal agencies. They also have distributed thousands of blankets, thin mattresses and personal hygiene kits.

Fox News' Griff Jenkins and Jake Gibson and The Associated Press contributed to this report.