Shaken by its worst economic crisis in 50 years, Mexico moved late yesterday to reduce chaos along the U.S.-Mexican border caused by a massive devaluation of the peso.

The Mexican Budget and Planning Ministry promised to subsidize U.S. food imports to relieve shortages aggravated by an invasion of bargain-hunting Americans who have crossed the border since the devaluation Aug. 5. They have been buying milk for as little as 17 cents a quart and sugar priced as low as 7 cents a pound.

At the same time, California Gov. Edmund G. (Jerry) Brown Jr. asked President Reagan for help for American merchants hurt by the loss of their Mexican customers who can no longer afford to buy American products with their devalued pesos.

Brown, who was asked by the Calexico Chamber of Commerce to declare the state's border area an economic disaster zone, asked that Reagan create a new economic assistance program for border cities and declare San Diego and Imperial counties immediately eligible for such relief.

On the Mexican side of the border, the Budget and Planning Ministry promised subsidies to Mexican border merchants facing debts they owe in suddenly inflated U.S. dollars. Many Mexicans have also found that their American dollars have been frozen in Mexican bank accounts, and that they soon will no longer be able to use their American Express credit cards outside the country.

Tijuana customs chief Francisco de la Madrid said in an interview here that promised but unspecified "export controls" by the government may include rationing of essential food items like milk and sugar.

The Mexican government's move to shore up the economy of the border region forms an important part of its effort to revive its entire economy, now nearly collapsing under the weight of huge foreign loans that the country has not been able to repay because of slumping oil revenues.

The Mexican and U.S. economies at the border are so entwined that the fall of the peso has brought what some U.S. merchants north of the border say is a 20 percent decline in their business at the same time that poor Mexicans south of the border are being further impoverished by the crisis.

The peso lost about half of its value in the Aug. 5 devaluation. On the free market today each U.S. dollar was valued at 130 pesos. Mexican unemployment and underemployment is estimated to have reached 40 percent. Inflation is expected to reach 100 percent by the end of the year. Mexican officials are continuing to fly around the world attempting to negotiate new loans and delay payment of those loans already due.

Border Patrol officers at El Paso blamed the worsening conditions in Mexico for an upsurge in the number of Mexicans attempting to cross the border illegally. The value of Mexican paychecks has shrunk at a time when Mexicans traditionally try to enter the United States to seek temporary farm jobs.

The El Paso section of the U.S. Border Patrol reported arresting a record 1,205 illegal aliens trying to enter from Mexico during a single day this week. The previous record of 989 was also set this week. The old record was set on July 4, 1978, when 951 illegal entrants were seized.

At the same time Americans are flooding across the border into Mexico to take advantage of the enormously increased buying power of their dollars there. Customs chief de la Madrid said the number of cars driving under his office, which overarches the main road into Tijuana, is up 30 percent from last year.

At the Calimax supermarket in Tijuana only two miles from the U.S. border, Americans today flooded the aisles with their full shopping carts as the buying spree stimulated by the devaluation continued. "It's unbelievable," said Bill McDermott, 40, a mechanic from Alpine, Calif., just over the border. "You can get filet mignon for less than $2 a pound."

Howard Freeman, 50, a refrigerator salesman from Chula Vista, Calif., said he came here to fill up his camper with 28 gallons of gasoline, now selling for about half the U.S. price. He said his wife, who is Mexican, has been upset about some of the U.S. hoarding. "She saw some people with three shopping carts full of nothing but meat," he said. "That's just stupid."

Unfortunately for merchants on the other side of the border, Mexicans who often shop in the United States are no longer able to get anything approaching a favorable exchange rate for their pesos and have found that their dollar accounts in Mexican banks have been frozen or severely restricted.

American businesses catering to customers south of the border have been hard hit. Freeman said the Montgomery Ward's store where he works does not depend very much on Mexican customers but "Sears in Chula Vista is really hurting."

Some chamber of commerce officials north of the border have said they are afraid some stores will go bankrupt if government aid does not reach them.

American Express announced today that its 270,000 Mexican cardholders could no longer use the card to charge expenses abroad. It gave Mexicans who are traveling outside the country until Sunday to pay their hotel and food bills and buy their air tickets with the card. Other credit card companies are said to be considering following suit.

The border economy suffered even more than the rest of Mexico because so many residents here earned dollars or traded them in their businesses. Many also imported goods from the United States and held American department store charge accounts.

In an announcement late Thursday, the Mexican official news agency Notimex reported, budget and planning officials said:

Mexican border residents with U.S. debts would be able to buy dollars from banks at a preferential exchange rate of 49.50 pesos to the dollar to pay the interest, but not the principal, on those debts.

The Mexican government would subsidize imports from the United States of staple foods in short supply here by making up the difference between the controlled and free market exchange rates.

All contracts drawn up in dollars within Mexico, including rents and service, would be paid in pesos at a below market rate of 69.50 pesos to the dollar.

Border merchants promoting the sale of Mexican goods to replace dollar-draining American items would get a 10 percent tax rebate.

De la Madrid, 55, brother of the governor of the state of Baja, Calif., applauded the influx of American buyers and said the government and merchants would be able to make up for any temporary shortages in supplies. "The prices on our clothing are also very attractive," he said. "And if you wish to visit Mexico by plane it is much cheaper to go to Mexico City from here, and the hotel prices are also very low."

He said he felt the stretch of border near Tijuana had not seen an unusual increase in attempted illegal crossings because "we have enough jobs to go around here. There is lots of construction going on in Tijuana at present."