When Mexican President Jose Lopez Portillo visits President Carter Friday, the scenario is likely to be very different from the many past occasions when leaders of the two nations have come together to exchange vague "hands-across-the-border" platitudes.

Even this latest meeting isn't expected to produce any sudden or dramatic initiatives. But it could someday be remembered as the launching pad for a significant change in relations between the neighbors, one that would see Mexico playing an increasingly high-priority role in U.S. foreign policy interests.

The difference involves oil. The vast amounts of oil that have been found in Mexico could prove to be a big factor in the efforts of an oil-hungry United States to extricate itself from an energy crisis by lessening its dependence on supplies from distant, politically unstable oil-producing regions.

Whether Mexico actually will turn out to be what a National Security Council study last December described as "the most promising new source" of oil for the United States in the 1980s is still an open question.

But Lopez Portillo will be coming here against the background of what U.S. officials regard as a potentially encouraging sign of things to come -- an agreement on sales of Mexican natural gas to the United States worked out last week after two years of difficult and frequently acrimonious negotiation.

The significance of the gas agreement is more symbolic than real, as it will provide the United States with only one-half of 1 percent of its needs at a cost higher than U.S. consumers have accustomed to paying.

But from the standpoint of U.S. officials wrestling with the energy question, the gas agreement is a heartening portent of possible deals to tap the United States into Mexican crude oil reserves, estimated at more than 40 billion barrels.

For Mexico, the oil factor has an importance that transcends the financial windfalls that traditionally proverty-ridden country can expect. Lopez Portillo, the leader of a nation whose population will reach 120 million by the year 2000, sees Mexico's oil as the bargaining chip that could alter Mexico's traditional "poor neighbor" relationship with the United States and force Washington to be more understanding of and deferential to Mexican interests.

Even before last week's agreement, Lopez Portillo had made clear that he was coming to Washington to talk not about gas sales but about other U.S.-Mexican points of contention, involving everything from the treatment of illegal Mexican workers in this country to the kinds of tomatoes that U.S. shoppers will find on their supermarket shelves in coming winters.

The fact that Lopez Portillo will be getting a respectful hearing on such touchy topics underscores how much the U.S.-Mexican equation has changed in the 2 1/2 years since he and Carter almost simultaneously assumed the presidencies of their nations.

When he first visited Carter in February 1977, Lopez Portillo was almost desperate for U.S. help. His predecessor, Luis Echeverria, had come close to bankrupting Mexico with his free-spending policies, had stirred up widespread domestic political turmoil and had alienated Washington through constant criticism of U.S. foreign policy.

But the Carter administration, in the throes of settling into office, had neither the time nor the inclination to listen to Mexico's problems. The visit generally was treated as a ceremonial nuisance, the Lopez Portillo was put off with a few vague, pro-forma promises that were quickly forgotten.

Nor did the situation improve when Carter trekked down to Mexico City last February. That exchange was notable for Carter's embarrassing public reminiscence about his experience with "Montezuma's revenge," and a Lopez Portillo speech, intended as an attempt to explain Mexican attitudes, that was widely interpreted in this country as a rude scolding of Carter and the United States.

In the interim, there have been myriad other frictions. One was the gas agreement impasse caused when former energy secretary James R. Schlesinger quashed the original deal, made two years ago between Mexico and a consortium of six U.S. companies. Another was Lopez Portillo's angry outburst last month when Robert C. Krueger, Carter's special ambassador-designate for Mexican affairs, called for negotiations on compensation for the Mexican oil spill washing up on Texas beaches.

Even in the foreign policy field, many Americans with an interest in Mexico have been alarmed by what they regard as signs of Lopez Portillo continuing the anti-American, Third World-oriented policies of his predecessor, Echeverria.

In spite of these discords, there are signs that the two leaders are preparing for a new attempt to establish an improved relationship.

In part, that's a result of the United States' increasing interest in Mexico's gas and oil in the wake of this summer's gas lines and the shock waves the gas lines sent through the U.S. political system.

But it's also a result of a growing appreciation among Carter administration officials of Lopez Portillo's success in relieving the political and economic stress that he inherited and in restoring a strong measure of internal stability to Mexico.

Despite his occasional outbursts against the United States and his grandstand plays to mollify the leftists in his power base, Lopez Portillo has made great strides toward regaining the confidence of the domestic and foreign business communities, who were at constant loggerheads with Echeverria.

As Krueger points out, "During the first eight months of thie year, more foreign investment went into Mexico than during the previous five years. And of that amount, more than 90 percent of it came from the United States."

In the foreign policy area, after the radical rhetoric is sifted out, it has become increasingly clear that Lopez Portillo is steering a basically moderate course. In Nicaragua, for example, U.S. diplomatic sources say that Mexico has been using its influence with the radical Sandinista movement in control there to counsel moderation and to keep Nicaragua from falling under the domination of Cuba.

Washington has been shifting toward a position that Krueger summarizes in this way: "When one of two partners is growing in strength, there inevitably is going to be growing pains in the relationship.

"During the period of change, there will be certain frictions that weren't present before. But we ought to be prepared to accept that, because over a period of time, our relationship will be strengthened by having a strong rather than a weak and dependent partner."

In seeking a new approach to Mexico, administration officials have been taking another look at the National Security Council study, known officially as PRM-41, which was prepared last year and then put aside.

The study set forth a number of policy options ranging from maintaining the traditional U.S. view of Mexico as an "emerging power" in the Third World to viewing it as a world-scale power entitled to special export concessions and immigration quotas, in exchange for increased U.S. access to Mexican oil and gas.

Of the nonenergy issues expected to dominate the talks between Carter and Lopez Portillo, the most sensitive involves the question of illegal immigration. Of the three million to eight million illegal aliens in the United States, U.S. officials estimate that 60 percent are from Mexico.

For Mexico, with its chronic unemployment and underemployment rate of 45 percent, the ability to send workers across the border either temporarily or permanently in an important safety valve for domestic tension. For that reason, the Mexican government has no enthusiasm for efforts to stem the tide.

In the United States, though, illegal immigration is an increasingly sensitive political issue that could become particularly troublesome if economic recession hits those areas where Mexican illegals are most concentrated.

The Carter administration's one attempt to deal with the problem -- a complicated program of amnesty for illegal aliens already in the country coupled with stricter border surveillance -- was stillborn because of congressional reluctance to act on the plan.

Another subject certain to come up in the Carter-Lopez talks is Mexico's complaint that it is being restricted unfairly from exporting tomatoes and other winter vegetables to the U.S market. After heavy pressure from Florida and southwestern agribusiness interests, who charge that Mexico is undercutting their markets, the Treasury Department instituted a dumping complaint against Mexican exporters.

The Treasury action subsequently was withdrawn under an agreement that the State Department would try to negotiate a vegetable agreement with Mexico. But the negotiations have moved slowly, and Mexico has chafed at what it regards as an attempt to maintain a trade balance tilted in favor of the United States.

None of these controversies is likely to be resolved in a mere two days of talks. But Lopez Portillo, who is quite aware of the trade-off themes discussed in the PRM-41 study, knows that because of his nation's oil, he is coming to Washington in probably the strongest bargaining position ever enjoyed by a Mexican president.