After two months of near panic over the sharp plunge in oil exports, Mexico is now close to recovering its foreign markets despite the continuing glut in world oil supplies.

The Mexico-U.S. oil deal announced in Washington today is the latest in Mexico's strategy of seeking long-term contracts with large oil conglomerates and governments that seem more reliable customers than small commercial companies prone to market pressures.

By making deals with a government, so the thinking here goes, Mexico can also link its crude sales to other commercial transactions or investment projects and thus leave it less vulnerable to the fluctuations of oil supply and demand that have hurt Mexico this summer.

The new U.S. contract involving 24 million barrels of crude in 1981, according to the state oil company Pemex, "will more than compensate for the drop in exports in July."

Sales dropped so drastically that Mexico's income from oil this year is now expected to be $5 billion short of the previously expected $20 billion and the government has cut back its overall expenditures by 4 percent.

Anticipating possible protest from nationalists and leftists at home and members of the OPEC cartel abroad over the Mexican input into the U.S. Strategic Petroleum Reserve, the statement also stressed that this sale would not violate the stated policy of selling no more than 50 percent of Mexico's imports to the United States.

As Mexico once again is reaching its earlier export level of close to 1.4 million barrels per day, officials appear to be recovering from the shock that came in July when Mexico saw its exports dive by almost one-third.

The drop, the result of a mix of declining demand and oversupply of oil in the world and a series of price miscalculations here was a rude awakening from the euphoria of the fast-growing oil power.

In less than five years, Mexico moved up to become the world's fourth-largest oil producer, with proven hydrocarbon reserves of 67 billion barrels. The dizzying flow of oil and revenues became the pivot of a national development plan and economic boom as well as the first source of real leverage Mexico felt it had ever gained in its uneasy dealings with the United States.

But the midsummer oil export falloff here has also brought to the surface many of the economic and political problems Mexico is facing as a result of the headlong rush into financing of development through oil. Although officials here have carefully studied the economic and political pitfalls of other oil powers, Mexico soon found itself similarly trapped.

Within three years, the country moved from an economic recession into an overheated economy with rampant inflation. For the first six months of this year, oil and gas exports accounted for 74 percent of Mexico's foreign exchange earnings.

As other oil nations began to offer unofficial discounts for their crude oil this summer in face of the oil glut, this sent shockwaves through a government that had become enormously dependent on oil revenues.

In June, Pemex's powerful chief, Jorge Diaz Serrano, was forced to resign after he lowered Mexico's oil prices by $4 per barrel. His move was prompted by the cancellation of contracts by four American companies. Other clients were threatening to do the same.

Although oil industry experts at the time argued that his economic decision was sound, President Jose Lopez Portillo called it "hasty and premature." Diaz Serano, it turned out, had not held enough political consultation. And the Mexican government, for whom oil is a nationalist symbol, was embarrassed to be the first exporter to announce an official price cutback.

By the end of June, Natural Resources Minister Jose Andres de Oteyza, Diaz Serrano's main political rival, raised oil prices again by $2 as a sort of national vindication.

The result was a rash of suspensions and cancellations of contracts even from trusted clients such as France and Japan, who reportedly stopped buying altogether in July. Furious, Mexico told France that this would mean the end of Mexico's multi-million-dollar imports from France.

Although Pemex has declined to disclose the official figures, insiders here say cancellations had added up to nearly 800,000 barrels a day by July.

Although the July price increase of $2 per barrel has been quietly taken away again and Mexico is returning to its previous production levels, "life won't be quite the same again after July," one economist here said. The summer drop in exports triggered a rush from pesos into dollars of between $4 and $5 billion, according to unofficial estimates.

As a result of the cutback in revenues, earlier this month the government announced the unprecedented cutback in federal expenditures.To slow the fast-growing foreign debt, the government has imposed new licenses and tariffs.

"Compared to other countries of course the picture here is nowhere grim," said one foreign oil expert, "but there is a difference. When the U.S. government wanted to buy oil for the Strategic Petroleum Reserve over a year ago, Pemex said it had none available. This time, Mexico was pleased to sell."

Over the past month, Mexican officials have made visits to old and

Over the past month, Mexican officials have made visits to old and potentially new clients for its crude. France and Japan have both resumed their purchases of 100,000 barrels per day while Japan is expected to buy another 200,000 barrels per day by the end of the year. Moreover, Mexico expects to increase sales to Spain, now at 198,000 barrels per day. But American companies still buy the single largest portion of Mexican oil.