The Mexican government has adopted harsh new austerity measures this summer to brake the overheated economy and prevent inflation from soaring out of control.

The new effort indicates that President Miguel de la Madrid is returning to the tough, anti-inflation policies that characterized the first 18 months of his term in 1983 and early 1984. His government relaxed those policies in the middle of last year and pumped up the economy in an apparent attempt to please voters prior to the midterm nationwide elections July 7.

The Mexican policy shifts mirror the dilemma faced by a half dozen Latin American democracies saddled with runaway inflation and enormous international debts as they try to restore economic solvency without political upheaval.

The measures have dashed hopes that economic growth this year would cut into Mexico's chronic problem of joblessness. More than 40 percent of the work force is believed to be unemployed or underemployed, and it has been three years since the economy created enough jobs to match the increase in population.

Moreover, some of the new measures will have the short-term impact of adding to inflation. For example, a 20 percent devaluation of the peso, increasing the number of pesos needed to buy dollars, will make imported goods more costly.

The Congress of Labor, which represents 34 unions, criticized the new policies and said that, as a form of protest, it would demand larger wage increases than originally planned.

In the long run, however, the policies were expected to restrain inflation by slowing growth, trimming the government's budget deficit and forcing industry to become more competitive, according to Mexican and U.S. government officials and private economists.

The first sign of the new austerity came in June, when the Bank of Mexico sharply tightened monetary policy in a deliberate effort to end a "boomlet" of rapid economic growth. The rate of growth now is expected to fall to zero by the end of the year, private economists and diplomats said.

Since the elections, the government has followed up by devaluing the peso and announcing major cutbacks in the bureaucracy. It also lowered trade barriers that had helped to protect industry against foreign competition.

"We were going a little too fast," Treasury Secretary Jesus Silva Herzog said. "We have had to take some severe actions."

Inflation was expected to drop modestly from last year's rate of 59 percent, whereas it would have risen sharply without the new corrective measures, private economists and diplomats said.

The U.S. government and banks have welcomed the policies as evidence that Mexico is renewing its commitment to austerity. Both Washington and Wall Street watch Mexico's economic performance with particular interest because U.S. banks hold the bulk of this country's $95 billion foreign debt, largest in the Third World after Brazil's.

Mexico has been considered the "good student" among Latin American debtors because of de la Madrid's willingness to fight inflation since he took office in December, 1982. But some U.S. bankers and economists recently aired concern that falling world oil prices would force Mexico to renegotiate some of its debt, or would jeopardize its ability to keep up with its interest payments.

"We consider these steps to be important and significant, and they should have beneficial effects both immediately and in the longer term," Secretary of State George P. Shultz said of the new measures during a visit here late last week for routine talks. Acknowledging that past austerity measures have required "significant sacrifices by the Mexican people," Shultz noted that "we are heartened to see Mexico's determination to continue."

De la Madrid's administration cut inflation from a record high of nearly 100 percent in 1982, to just under 60 percent last year, at a cost of the worst recession in Mexico's modern history.

In the middle of last year, however, the government eased monetary policy and began to raise public spending. The economy surged, and gross domestic product rose by 3.5 percent for all of 1984 instead of by the original target of about 1 percent.

The pickup in the economy carried over into the start of this year, when economic growth accelerated to an average annual rate of about 6 percent for the first six months. However, the speedup raised inflationary pressures, and it encouraged Mexican companies to sell on the growing domestic market rather than to export and bring in much-needed foreign exchange.

"The government reflated in the middle of last year, fundamentally with a view toward the elections. They transferred a lot of their problems to 1985," the chief economist of a leading private research group said.

By this spring, the difficulties caused by the spurt of growth were becoming increasingly evident. The government was backing off from its previously declared goal of lowering inflation to about 40 percent, and the country's trade surplus was reduced by approximately one-half during the first five months of the year. Much of this worsening of the trade balance resulted from the weak oil market, but nonpetroleum exports also fell by 12 percent from the comparable period of 1984.

The combination of resurgent inflation and a deteriorating trade balance led to a run on the peso in May and June. The Bank of Mexico had been carrying out daily devaluations of the peso at an annual rate of 33 percent, but this was not considered adequate, given that inflation was expected to surpass 50 percent.

The government hoped to postpone a devaluation until after the elections, but speculation grew too strong and it had to act. It removed exchange controls on pesos sold to tourists and to businessmen in selected industries, and the Mexican currency plummeted from about 250 pesos per dollar to more than 350 pesos in less than a month.

While tourists enjoyed a boon, most commercial transactions still were governed by the old, "controlled" rate. After the elections, however, this rate also was devalued. De la Madrid signaled that the peso would continue to fall by whatever rate was necessary to preserve the competitiveness of exports.