THE FIRST priority for the Mexican government is to stop the panic-stricken rush of money out of the country. To do that, as the government has now demonstrated, it is prepared to go to extraordinary lengths. The nationalization of the banking system was necessary, President Lopez Portillo decided, to provide assurance that the government's exchange controls would actually be enforced.

The peso's long slide began with weakening oil prices and domestic inflation. In January, the peso traded at 27 to the American dollar. In February, it fell to 45. In early August, when the government announced that it could no longer continue to support even that rate, it fell to 77. Since then, the movement out of the peso has turned into a stampede. People have been struggling to get their wealth into other currencies by carting it in suitcases across the border, by hastily moving bank deposits around, by selling securities to raise portable cash. Currently the peso is trading at about 120 to the dollar.

Exchange controls are never an attractive remedy. They are hard to operate and harder still to operate fairly. The initial impact fades fast. That's particularly true in a country like Mexico, with an open economy, a big tourist industry and close ties with financial centers abroad. It doesn't take the sharp-pencil crowd long to figure out ways to move capital disguised as the normal flow of trade.

The government believes that if it can only stop the panic and the flight of capital, with even the most temporary of means, the basic strength of the economy will shortly reassert itself. Otherwise the falling currency feeds the inflation, currently somewhere around 100 percent a year, and that in turn incites greater panic.

From the United States and Europe, Mexico urgently needs loans to restore at least a temporary balance while it tries to rectify the deeper dislocations in its economy. Here the Reagan administration deserves credit for having risen rapidly and ably to its responsibilities. That represents a triumph of friendship and wisdom over the administration's professed doctrine of nonintervention.

But for the Mexican people, the hardest part still is months in the future. When the outpouring of capital, and the fall of the peso, are finally halted, Mexicans will have to begin coming to terms with the realities that started it all in the first place. Those realities are the imports that far outran exports even in the years of the oil boom, and the incomes that shot far beyond anything that the country could afford. Then come the unpleasant questions about cutting back, and where and at whose expense. Mexico is still in the financial and technical phase of dealing with a great cycle of overspending. The political and social phases still lie ahead.