In the short span of less than two years, the Mexican economy has shifted from crisis to recovery, with bankers banging on the door for the privilege of lending big money to the most populous Spanish-speaking country in the world.

A new administration under President Jose Lopez Portillo, responding to an austerity program designed by the International Monetary Fund, restored confidence, put the brakes on a panicky flight from the Mexican peso, and cut the current account deficit nearly in half.

The peso, which former president Luis Echeverria allowed to float on Aug. 31, 1976, has stabilized at about 22.5 to the dollar, a devaluation of about half of the old 12.5-to-1 ratio.

In addition to a classic squeeze designed to bring an overextended public sector back to reality, new oil discoveries well add untold wealth to Mexico, enough to make it a surplus rather than a deficit country. No one knows just how much oil there is, but Mexico clearly outranks Venezuela, and some say, could in time rank about equally with Kuwait or Iran.

Yet, for all of its potential in oil and other extensive mineral and forest resources, the Mexican economy is far from over the hump. The hard fact is that Mexican growth and development is outpaced by population under Lopez Portillo's highly touted recovery no less than it was under Echeverria's recession, the builk of Mexico's 63 million people are poor, and getting poorer by most measures.

But as a showcase of the developing world, Mexico is a hot item, and once again highly attractive to foreign investors.

"Mexico is a good risk," Citibank Chairman Walter Wriston said at a bankers meeting here last week. "Not only do they have good technocrats managing the government, but they are blessed with oil."

The largest investment by any non-Mexcian bank is that of the Bank of America, which makes the assessment of President A.W. (Tom) Clausen especially intersting:

"Bankers are strange peopls," he smiled. "When the temperature comes down from 105 degrees to 103 degrees, they say, 'Great.'

"Now, I don't say that the temperature in Mexico is 103 degrees. Maybe it's only 101. But they still have some way to get back to normal."

Two years ago, Mexico was the prototype of the less developed country that had overcomitted itself. And if Mexico and the other LDCs had overborrowed, then the banks putting up money would be in trouble, too.

That fear has largely been put aside, and the U.S. even has a new designation - ADC (advanced developing country) - for Mexico, Brazil, and Korea. But continued inflationary pressures, here are a prime worry."Mexico can't live with an inflation rate double the rate of the United States," said Jeremy Morse, chairman of Lloyds Bank of London.

On the plus side, the balance of payments on current account was cut from $3 billion in 1976 to $1.8 billion in 1977, in part reflecting increased oil exports. The deficit will rise to $2.5 billion in 1978 but for a good reason: additional capital goods imports that will increase oil production.

Like Wriston, Clausen, places great faith in the Lopez Portilo government and the capability of men such as Finance Minister David Ibarra Munoz. Essentially that could be more important than oil, "because good managment is what can make an economy strong," Clausen says.

Ibarra takes pains to assure a visitor that the millenium hasn't come. He stresses that the economy is still undergoing a period of adjustment. But he predicts that economic growth, which had dropped to near zero from Mexico's consistent 6 to 7 percent in the 1960s and early 1970s, will start up again.

The 1977 growth rate was 2.8 percent, and Ibarra is predicting about 5 percent for this year. "That's not such an ambitious target," he said in an interview.

But Redvers Opie, an economist based here who has had long experience dealing with the Mexican government offers a note of caution: Mexican statistics are not as complete or accurate as in the developed world.

"There is no analytical basis for the 5 percent growth forecast," Opie warns. And as against the government's claim that consumer inflation has dropped from 30 percent in 1976 to 21 percent in 1977, and to a likely 15 percent this year, Opie says that the best measure of inflation, the implicit price deflator, was 36 to 31 per cent in 1977, an all-time high.

What does not emerge too clearly to the outside world is that Mexico for all practical purposes is a one-party state. The Institutional Revolutionary Party (PRI) elects not only the head of state but almost all of the congressmen and state officials.

And Lopez Portillo is the boss. "By and large, what Lopez Portillo says, goes," says a Western diplomat. He was able to see the wisdom of accepting the IMF stabilization program, even though it meant reducing the public-sector deficit from 10 percent to 6 percent of gross domestic product between 1976 and 1977 and cutting additional borrowing from abroad from $6 billion to $3 billion.

This meant persuading the unions to moderate demands, a task that Lopez Portillo appears to have carried off with great skill. "He's been able to sell them that this is in their own self-interest," says a Mexican central banker who asked not to be identified.

Thus, inside and outside his country. Lopez Portillo has achieved the image of a man who can be trusted, whereas Echeverria's well-intentioned but hasty efforts to redistribute income through land reform scared the business community to death.

"Whether it was perception or reality, the Mexican business community feltthat Echeverria really was antibusiness," says a World Bank analyst. "And when it came to land reform, Echeverria really was antibusiness.

"But what was really hurting the business community was Echeverria's economic management policy. Echeverria wanted to spend money for rural development, for poor farmers, and for education. But he couldn't raise the revenue for the public-sector deficits he created. It was a textbook case of mismanagement."

After a fantastic record of more than 20 years of economic stability, the Mexican economy neared a collapse, and Echeverria had to take the rap for devaluing the peso, and had to watch the beginnings of a flight of pesos into 4 billion dollars, as he waited for Lopez Portillo - who earlier had been his treasury minister - to succeed him.

To pay for his excesses, Echeverria went abroad to borrow the money. The foreign debt grew from less than $3 billion in 1970 to $14 billion in 1976 and $20 billion in 1977. Unofficial estimates are that Mexico's outstanding debt may be $26 billion by the end of this year.

Bankers at that time didn't question the good faith of Echeverria, or whether their loans merely were supporting an overvalued peso. Now they look more closely at what a country is doing with the money (and the American government is keeping a closer tab on individual bank exposure).

The IMF-Lopez Portillo belt-tightening, combined with the oil finds, clearly have put Mexico on the road back toward solvency. Ibarra's prediction that Mexico will have a balance of payments surplus in two to three years is wholly believable.

But the basic problem - too big a population growing at explosive rates - hasn't been solved, and the outlook is grim.

At the mement, the safety valve is illegal immigration into the American Southwest. The "illegals" can be absorbed - and are even welcomed - in the present volume. But what will happen as the population soars?

Mexico gets its showcase reputation as one of the successes in the less developed world from incredible natural resources ("They don't even know what they've got in minerals," says Opie) and a per capita income of about $1,000 to $1,200.

But the government itself estimates that unemployment is 25 or 30 percent and, if the underemployed are counted, the figure comes closer to 50 percent. There is, in fact, nohard and fast figure on unemployment that is worth much.

A better way to assess Mexican poverty is to look at the distribution of income, according to experts at the World Bank. And what this shows is that the disparity between the rich and the poor is growing.

According to Clark Reynolds of Stanford University's Food Research Institute, Mexican per capita income increased in constant dollars from $375 at the end of World War II to more than $1,000 in 1976.

But he poorest 10 percent, or about 6 million, have an income of only $400, while the upper 10 percent average $3,700-or about nine times greater than those at the low end of the scale. Some World Bank studies put the disparity even higher.

And as Reynolds points out, the per capita average income of the whole population just across the border is higher than the upper 10 percent in Mexico, which means that an illegal can make more in just a few months in the United States than in an entire year at home.

At any given time, there may be 2 to 3 million Mexican illegals working in the U.S., and astonishingly high figure in relation to the small Mexican labor force total of only 14 million.

Every year, at least 800,000 (it may be as high as 1 million) come into the labor force. They drift from the countryside to the cities looking for work or food. Squatter communities ring the cities, especially Mexico City, which adds about 750,000 to its numbers every year.

With a high birth rate, the population will be between 115 to 130 million by the year 2000. A belated birth control program now blessed by the government can have only marginal effects on population for the rest of this century.

Of the entrants to the labor force yearly, at least 600,000 won't find jobs in Mexico, even at a 5 percent growth rate. The jobless continue to pour into the cities because Mexico is actually land-poor and water-poor, with only 15 percent of the land area arable.

Over recent years, agricultural expansion has suffered,contributing to the poverty problem. In the 1940s, Mexico had achieved self-sufficiency in food. But in the 1950s, the emphasis shifted to industrialization and, by the 1960s, Mexico had to import food - even corn, a staple in most Mexicans diets.

Like foreign bankers, the Mexican government is putting a lot of faith in oil, and it certainly can provide a dramatic thrust to the economy. Ibarra told the bankers conference that the Tabasco finds by Pemex, the state oil monopoly, would mean total production of 2.5 million barrels a day by 1980, two years ahead of schedule.

According to a new Bank of Mexico report, total proven reserves at the end of 1977 reached 16 billion barrels, a 43 percent increase over the previous estimate. Reserves might hit 30 billion barrels by 1982, according to some.

But oil alone won't solve Mexico's long-term Problem of overpopulation, although oil wealth can ease Mexico's problems over the next 10 or even 20-years.