NEW YORK -- For all the Reagan administration's efforts to resolve the Third World debt crisis, the longstanding rivalry between two big banking companies here -- venerable J.P. Morgan and brash Citicorp -- played a far bigger role in creating last month's dramatic breakthrough on Mexico's foreign debt payments.

Last May, while Treasury Secretary James A. Baker III was formally opposing any acknowledgement that Third World nations would not be able to fully repay their huge debts, Citicorp Chairman John S. Reed set the stage for a new understanding by abruptly announcing that he would set aside $3 billion to absorb potential losses on the bank's Latin American loans.

The move stunned and infuriated many bankers and government officials because it was unilateral and came without warning. But with the young and relatively new Citicorp chairman receiving widespread acclaim outside the industry for finally admitting the obvious about Third World debt, Morgan's chairman, Lewis Preston, wanted to recapture the initiative, industry officials say.

Within weeks, Morgan officials presented Mexico with their own innovative approach. Baker was brought into the planning only a couple months ago, when Mexico asked the U.S. government for help in putting together the final pieces of the puzzle.

The result was a complex plan, involving up to $10 billion in Mexican bonds backed by a new issue of U.S. Treasury securities, that would allow Mexico to retire between $5 billion and $10 billion of the $78 billion it owes to international banks with a relatively modest cash outlay. The banks, in return for accepting less than face value on current unsecured loans trapped in their portfolios, would receive from Mexico a more secure bond that would be freely tradable on the open market.

"Nothing beats revenge as the mother of invention," one senior banker at a major regional company said. "Citicorp may have forced everyone to start dealing with reality, but Morgan has now established a new framework for a positive approach to the problem."

And Morgan officials, while praising the Treasury for its support, acknowledge that they could have put together a similar deal without official U.S. government help simply by purchasing the Treasury bonds, which will be used as collateral on the open market and will not cost the government anything.

"After five years, you had creditor fatigue and you had debtor fatigue," Dennis Weatherstone, Morgan's president, explained. "The timing was right for a different kind of solution."

The jockeying between Morgan and Citicorp over Third World debt is only one of many recent cases in which the major banks are dragging government officials along in key economic policy arenas. Now Morgan is helping to lead the assault on the Depression-era Glass-Steagall law, which prevents banks from entering the securities business and keeps banks and securities firms from competing against each other.

"We have been preparing for these new opportunities for some time and have been disappointed at the rate of progress," Weatherstone said. "The world has changed. Our customers' needs have changed because we're in a global marketplace. ... By necessity, it's time to open up these markets to improve their efficiency."

For Morgan, such activity is particularly intriguing. Morgan Guaranty, J.P. Morgan's commercial bank, has long been one of the stodgiest and most private of the nation's major banks. Despite having the strongest capital of the big U.S. banks, it was the slowest to follow Citicorp last year in boosting its reserves against potential Third World debt losses.

But buoyed by its recent success, Morgan has been coming out of its shell.

The Mexico-Morgan proposal marks a major turning point in the struggle to ease some of the burden that is holding down the world's deeply indebted countries, mostly in Latin America but also including the Philippines. Although Mexico -- with much more foreign exchange in its coffers than most other debtor nations and with a record of improved economic performance -- is uniquely situated to buy up its own debts, other countries should be able to take advantage of similar plans.

"Each one may have to be tailor-made for other debtor countries," Weatherstone said, "but if this deal is successful, we think there will be opportunities for other countries fairly promptly."

Already, Venezuela, Latin America's fourth-largest debtor, is looking at a similar plan to buy back part of its $33 billion of foreign debt at a discount, using a new issue of bonds as payment. Other countries lacking substantial reserves may look to Japan, West Germany, and the World Bank as potential sources of credit and guarantees for different kinds of debt payoff arrangements.

Before Morgan developed the Mexican debt scheme, commercial banks and government officials had been locked into a strategy demanding that debtor countries continue to meet interest payments on their full debts. At the same time, banks were being continually squeezed by U.S. officials to lend additional sums to tide the major debtors over until their economies could generate robust export surpluses to meet those increasingly burdensome obligations.

While avoiding government-imposed debt write-offs, the new approach creates a voluntary, market-oriented path for banks that helps shrink the existing pile of Third World debt rather than adding to the already immense $1 trillion in outstanding loans.

"In effect," said Richard E. Feinberg, vice president of the Overseas Development Council in Washington, which specializes in Third World issues, "Morgan Guaranty and the U.S. Treasury have joined the debt-relief club."

Under the plan, Mexico will be able to reduce its current debts, saving an estimated $400 million to $600 million in annual net interest costs. In exchange for eliminating between $15 billion and $20 billion of its current debts, Mexico will dangle in front of the banks the lure of receiving up to $10 billion worth of new bonds on which it will pay a somewhat higher interest rate than those on its existing loans.