The group were rounded up after trying to cross the border “violently” and “illegally” on Sunday, the ministry said in a statement.
Video footage shows dozens of people running towards the fence that separates the two countries near the city of Tijuana.
They were repelled by tear gas used by US border officers.
Mexico’s interior ministry said in a statement that a group of “nearly 500 migrants” had “tried to cross the border in a violent way”.
Those identified as having taken part in these “violent events” would be deported immediately, it said.
The ministry added that, “far from helping their objectives”, the migrants’ actions had violated the legal migration framework and could have led to a “serious incident”.
Tensions have been high in Tijuana since the arrival of thousands of migrants earlier this month.
The migrants are in Tijuana after travelling more than 4,000km (2,500 miles) from Central America.
They flee poverty in their home countries of Honduras, Guatemala and El Salvador.
However, they now face a long wait to see if their asylum applications will be accepted by the US, with President Donald Trump vowing to keep each migrant on the Mexican side of the border until courts have decided their case. This could take months.
The migrants growing impatient on Sunday, the group of about 500 migrants felt they are entitled to migrate into to the US and made a run for the border, they tried to force their way in.
Mexico’s Home Secretary, Alfonso Navarrete, said the group had asked for help to organise the demonstration, but had reportedly been encouraged by some of the movement’s leaders to split into different groups and try to cross into the US illegally and by force.
According to news agency AFP, a number managed to climb over the first fence. It was as they tried to cross a second, spike-topped wall that officials on the US side began throwing tear gas.
Honduran migrants from some of them from violent M-13 gangs were also repealed, on gang member said “you run the smoke smothers you more.”
As a result of Sunday’s action, the US closed the San Ysidro border crossing near Tijuana to vehicles and pedestrians for a time before re-opening it.
Mr Trump threatened to close the entire US-Mexico border earlier this week if it was felt the US was going to “lose control” of the situation.
He also said he had given troops at the border the go-ahead to use lethal force if needed.
Mr Trump has deployed about 5,800 troops to the border. He previously described the migrants as an “invasion”.