President Reagan said today that the Cancun summit, which ended here yesterday, was "a substantial success" that exceeded many expectations and marks a good beginning toward more constructive relations between rich and poor nations.

Like other leaders departing this Mexican resort after two days of 22-nation summitry on international economic problems, Reagan expressed pleasure at what had been accomplished.

"I've returned home reminded again of the importance of American leadership in the world," Reagan said as he arrived at Andrews Air Force Base.

The summit's main accomplishment was an agreement saying all 22 nations favored global negotiations within the United Nations on world economic problems -- something the developing countries came here hoping for and the United States had said it opposed -- but it gave little specific detail on how or when those negotiations will begin.

The practical agreement prevented Cancun from ending in a stalemate, which would have left the United States isolated not only from the Third World nations, but also from its allies on the questions of world economic development.

Secretary of State Alexander M. Haig Jr. said today the agreement did not represent "concessions" by the United States. He said "an evolutionary step forward" toward global negotiations had been taken, but he made it clear that the United States still has many conditions to be met before such negotiations begin.

Indian Prime Minister Indira Gandhi, the leader of one of the key nations in the developing world, said the agreement that emerged last night was "one small step." Gandhi was one of eight summit participants who held news conferences at the end of the meeting.

Haig said he visualizes that there will be informal discussions among those nations represented at Cancun and "other interested parties" that can take place at the United Nations and elsewhere.

At a news conference this morning, British Prime Minister Margaret Thatcher called it a "practical agreement among people who represent very different points of view."

Haig said the United States is "very comfortable" with the final statement, which was drafted by the summit's cochairmen, Mexican President Jose Lopez Portillo and Canadian Prime Minister Pierre Elliott Trudeau.

"I don't think you could describe the U.S. position . . . as one of concessions or nonconcessions," Haig said. "I have described the American position on this nettlesome subject as one of evolution -- a clarification of positions -- and the American position was clarified, and the whole issue needed clarification."

Thatcher, like other participants, described as Cancun's most significant decision that "global negotiations would go back to the United Nations in the form that the Third World countries wanted." But she noted that global negotiations mean different things to different nations.

The United States, with backing from other industrialized countries, won insertion in the conference's summary document of the provision that specialized agencies, such as the International Monetary Fund, the World Bank and the General Agreement on Trade and Tariffs, will remain in their present form, that is, controlled by the wealthy nations.

Gandhi took issue with Thatcher's statement that no one knows what global negotiations mean. The industrialized nations may have different understandings, she said, but "the less developed countries more or less share their concept of it."

Reagan said he reiterated the U.S. commitment to work with developing countries to stimulate economic growth. He said the other nations at Cancun indicated "broad acceptance of many of the approaches" that Reagan has proposed stressing the importance of free trade and private investment rather than development aid.

U.S. officials said that Cancun will reinforce antiprotectionist sentiment at the 1982 General Agreement on Trade and Tariffs meeting.

Haig also emphasized the personal role Reagan played here. Reagan, the secretary said, established "personal relationships that are, I think, warm, cordial and respectful in every instance and especially in those where you would expect them to be least so," referring to the leaders of developing nations. He added that those leaders have had an opportunity to look "at the behemoths from the north and vice versa and both found themselves devoid of horns."

Although the U.S. delegation was delighted by the noncontentious atmosphere at the summit, Reagan encountered some resistance as he stressed the advantages of private sector development.

Reagan was praising free enterprise farming during a meeting on food when Tanzanian President Julius K. Nyerere intervened. "Let me tell you something," Nyerere said, according to one of the participants at the conference table, "U.S. agriculture is the most heavily subsidized in the world."