The Mexican gas deal and the visit of President Lopez Portillo announce a change in the character of relations between this country and its neighbor to the south. But it is not, as sometimes imagined, the beginning of a glorious partnership. On the contrary, genuinely insoluble problems now dominate the Mexican-American connection. A danger zone lies ahead and the best hope is that it can be traversed without a blowup.

Volume tells the true story of the gas deal. Back in 1977 when the transaction was first conceived, the idea was that Mexico would send this country 2 billion cubic feet daily. Under the arrangements made public last week, the starting figure is only 300 million cubic feet a day.

Behind that drop lies a deliberate decision by the government of Lopez Portillo. Mexico is not going to follow the example of Iran, Saudi Arabia, Venezuela and others in pushing toward allout exploitation of petroleum resources for the export market.

Instead, Mexico is using much of its newly discovered gas as a substitute for coal in local industry -- notably in Monterey and Mexico City. It is developing its oil more slowly than originally anticipated. Exports only some of which come to the United States -- will now reach a million barrels a day until next year.

One consequence of the measured development is that Mexico will probably be spared a runaway boom with unmanageable inflation. But another consequence is that, while funding some projects, Mexico has also had to abandon the most ambitious plans for rural development. For the rest of the century at least, landless laborers will continue to pour out of the Mexican countryside, filling cities to the breaking point and creating irresistible pressure for the export of goods and people to the United States.

Already, thousands of Mexicans cross the border illegally every month. Some Americans are delighted to employ them in agriculture, factories, service industries and as domestics.

Other Americans, however, are done out of jobs. American law-enforcement agencies, particularly the border patrol, experience great difficulties with the problem. So there is an internal conflict with no resolution in sight.

The export difficulties are just beginning. The Carter administration has managed, pending the Lopez Portillo visit, to hold off a complaint from Florida growers against dumping Mexican tomatoes during the summer months. Even if that holds -- and it may not, given the battle shaping up between the president and Edward Kennedy for the Florida vote -- the issue of winter vegetables from Mexico will soon arise.

Oil and gas, moreover, have already made Mexico competitive with the United States in petrochemicals. With natural gas selling at about a third of the international price, Mexican firms will probably be able to undersell American companies in the United States itself on such items as fertilizer. Which in turn will set in motion further pressure for higher tariffs.

On top of all that comes a foreign policy issue. In keeping with the country's revolutionary tradition, and to damp down radical protests at home, Mexican presidents have tended to support left-wing movements in other parts of Latin America. Thus Mexico has been friendly with Castro and supported the Sandinistas in Nicaragua.

Under Jimmy Carter, the United States has moved away from confrontation with the left wing in Latin America. But Mexico, far from welcoming that step, has tended to displace its own policy toward the left -- as though obliged to keep a constant distance between its stance and that of Washington. Thus the Mexicans refuse to support American moves for joint hemispheric forces to secure the recent transition of power in Nicaragua.

In short, tensions abound. Mexico is going to be less able to help the United States meet its energy problem than originally supposed. Elements inside the two countries clash on issues of export and immigration. There is conflict on the basic approach to foreign policy.

Despite these difficulties, the Mexican-American relation can be managed. That is what the gas deal and the Lopez Portillo visit prove. But they also show that living with Mexico is going to be increasingly tough.