President Carter and Mexican President Jose Lopez Portillo yesterday concluded two days of talks that produced no dramatic results but that were described as improving relations between the two countries.

The Carter administration, whose ties with Lopez Portillo had been strained, viewed the visit as a chance to make a fresh start and underscore its intention to treat Lopez Portillo as a major world leader.

However, events transformed the visit into a relatively low-key affair -- partly because of Washington's preoccupation with the question of Soviet troops in Cuba and partly because an agreement a week earlier on Mexican gas sales to theUnited States had resolved the most immediate problem affecting the governments.

A number of other sticky issues involving energy, trade and illegal immigration still exist. But, as a joint statement by the two presidents made clear, there was a general understanding to put them aside for the moment and to chip away at them slowly rather than try for dramatic breakthroughs.

The statement's emphasis was on improving the formal consultative mechanism between the two governments and, as Lopez Portillo said on his departure, the meetings "served to prove that the lines of communication are alive and working."

There also was a hint of possible progress on compensation for damage to the Texas coast caused by an oil spill from a Mexican well in the Gulf of Mexico. Last month, Lopez Portillo angrily rejected a U.S. suggestion to hold compensation talks.

The cautiously phrased statement talked about exploring ways to avoid "degrading the environment" on both sides of the border. U.S. officials said privately this means Mexico has agreed to talk about the possibility of compensation along with Mexican complaints about water and air pollution originating on the U.S. side of the border.

Officials on both sides said the energy discussions were restricted to general, long-range problems and did not focus on any new deals for tapping the United States into Mexico's newly discovered vast reserves of oil.

On the sensitive topic of illegal immigration from Mexico, officials said the talks did not go beyond agreement on the need for better information about the scope of the problem and Carter's reassurance to Lopez Portillo that his administration will respect the rights of all persons in this country.

Because the problem is so immense, there has been a tacit understanding to refer immigration questions to study commissions in both countries. That agreement, essentially a temporizingi measure, means that the matter will not receive any priority attention until after next year's U.S. presidential elections.

Also pushed to the side with vague talk about "further negotiations" was a dispute triggered by charges from Florida farmers that Mexico is "dumping" tomatoes and other winter vegetables in the U.S. market by selling them below cost.

For Cavter, that issue is particularly sensitive because Florida has emerged as a key early battleground in his potential rivalry with Sen. Edward M. Kennedy (D-Mass.) for the Democratic presidential nomination next year. As a result, the White House has little enthusiasm for pushing the dispute at this time.

On foreign policy matters, the joint statement contained a line saying: "Both presidents exchanged points of view on the Caribbean." U.S. officials would only say the two leaders had briefly discussed the Cuba situation.

It is known, though, that in recent days the United States had sounded out Mexico and other key Latin American countries about the possibility of their support for U.S. measures against Cuba if the conflict over Soviet troops is not resolved. U.S. officials say privately that the response was disappointing, with the Latin Americans making clear they do not want to become involved.

However, the statement did contain a more upbeat note about U.S.- Mexican cooperation on helping the radicial new Sandinista government in Nicaragua make progress toward democracy. As an early supporter of the Sandinistas, Mexico has considerable influence in Nicaragua. And Washington hopes Mexico will use its influence to coax Nicaragua toward moderation and keep it from falling under Cuban domination.