Mexican President Jose Lopex Portillo today surprised the U.S. government and many Mexican analysts by refusing to enter into a trade agreement that the United States considers essential for improving economic relations between the two countries.

The United States has been lobbying the Mexican government for more than a year to join the international General Agreement on Tariffs and Trade (GATT), which would have significantly reduced trade restrictions between Mexico and the major industrialized nations of the world.

Because two-thirds of Mexican trade is with the United States, both Washington and Mexico City saw the issue as largely between their two governments.

The Mexican president earlier was known to be in favor of joining. But, without further explanation, he said today this was not "the opportune moment" for Mexico to sign the agreement, which has been under negotiation for many months and was believed to be virtually settled.

If Mexico joins GATT later, Lopez Portillo said, it would probably not obtain the favorable conditions as it would now. But he said that joining now would not give the country the flexibility it needs for its development.

According to its advocates, joining GATT would have encouraged Mexico to develop more efficient industries while allowing the country to import more foreign manufactured goods, thus reducing many consumer prices and diminishing Mexico's high subsidy to industry.

Opponents contend that Mexico would be overwhelmed by an influx of U.S. products while unable to make a dent in the U.S. import market.

The joining of GATT and the sale of oil have become the two major economic points of contention between Washington and the Lopez Portillo administration.

Lopez Portillo, in a speech today, said Mexico would raise its oil production by 10 percent to 2.7 million barrels a day by the end of the year to cover growing domestic consumption.