Mexico and its bank lenders today signed the first stage of a long-term, $49 billion loan agreement that international financial officials hope will mark the beginning of a less chaotic and threatening phase of the Latin American debt crisis.

The massive restructuring of Mexico's debts is the largest ever undertaken by commercial banks and is designed to give it time to rebuild its economy before it has to repay most of its maturing debts.

It also is designed to serve as a model for other major Latin American debtor nations such as Brazil and Venezuela. The debt package pushes off repayment of nearly all Mexico's debt that has fallen due since 1982 or will come due by the end of the decade and reduces the interest Mexico must pay. The total package represents more than half Mexico's $95 billion in foreign debts.

The agreement signed today covers nearly $29 billion of Mexican government debt. Another $20 billion in loans to Mexican government agencies will be refinanced between now and June. Mexico will repay several billion dollars in principal in the next few years -- it already has paid back $250 million -- but the bulk of the repayments will begin in 1992. Mexico will continue to pay interest.

More than 600 banks signed the agreement today. The remaining 100 bank lenders are expected to sign within a few weeks, Mexican and bank officials said.

"This is the beginning of the end" of the Latin American debt crisis, said William R. Rhodes, the Citibank executive who heads the committee of big banks that negotiates with Mexico. "There is still a long way to go." He said there are a number of countries with severe problems and that the resolution of the repayment of Latin America's $340 billion in foreign debts will have its "ups and downs."

Except for today's Mexican debt restructuring, and a similar one in the works for oil-rich Venezuela, the last few months have brought mostly "downs."

The International Monetary Fund, the international financial rescue agency that serves as both the monitor of debtor countries' economic performance and an additional source of badly needed cash, has cut off both Argentina and Brazil. Both countries have fallen far out of compliance with the economic programs they agreed to follow.

Observers are worried that the ill health of newly elected Brazilian President Tancredo Neves, the first civilian president in 21 years, could leave the country in political and economic chaos. Bankers and government executives said they detect a serious resolve by Argentine President Raul Alfsonsin to take needed austerity measures, but are concerned that with inflation running at 800 percent a year, standard measures to control it -- such as reductions in real wages and cuts in federal spending -- may not work.

Argentina has more than $45 billion in foreign debt and Brazil, with more than $100 billion, is the developing world's biggest foreign debtor. The failure of either of these countries to pay their debts could rock the international financial system.

Although both nations have fallen seriously behind in their interest payments, and Argentina still lags, no bank has called for a default and neither nation has made any move to repudiate its debts.

Smaller debtor countries like Chile and Peru also are having deep difficulties revitalizing their economies, controlling inflation and earning enough dollars from exports to pay their debts.

Although Mexico has had difficulties meeting the targets it agreed to with the IMF last year, it has shown improvement in reducing inflation and its budget deficit and in renewing economic growth. It also has accumulated about $8 billion in foreign reserve surpluses, funds it can use in an emergency to pay its foreign bills.

Mexican Finance Minister Jesus Silva Herzog, who touched off the so-called Latin American debt crisis 21 months ago when he informed bank lenders his nation had run out of money and could not pay its bills on time, said the signing of the long-term package "does not solve our debt problems. It is only a step in the right direction."

Silva Herzog pledged that Mexico would continue the austerity measures it instituted in 1983 to trim inflation and reduce its reliance on foreign borrowing. He said that those measures have a "heavy and high social cost" but that they will also "assure the establishment of a sounder base for sustained social and economic growth."

In the last two years Mexico has slashed government subsidies on a wide variety of basic products -- from tortillas to gasoline -- and has held down wage increases both to fight inflation and to cut the federal budget. Silva Herzog noted that in 1983 Mexico weathered a sharp recession, its first in 40 years, and last year returned to economic growth of about 3.5 percent. He said the country will strive to increase production at about the same pace in 1985 and accelerate to about 6 percent in 1986 and beyond. Annual inflation, running at about 100 percent in 1982, fell to 80 percent in 1983 and 60 percent last year.