"It was negotiation by exhaustion," Canadian External Affairs Minister Mark MacGuigan said of the Cancun summit's closing hours.

For two days, leaders and ranking officials from 22 nations, rich and poor, had talked to each other in a way that surprised and sapped them.

"It was an actual dialogue," a bemused French President Francois Mitterrand said afterward. "We actually interrupted each other."

Canadian Prime Minister Pierre Elliott Trudeau, cochairman of the summit, presided over most of the actual dialogue. He became a kind of Mike Wallace to the other heads of state, questioning them, cutting them off, adopting a rapid-fire moderating style honed in endless debates at Cabinet meetings and constitutional conferences with Canada's contentious provincial premiers.

According to one Canadian official, Trudeau put down his written statement and said he expected everyone else to do the same. When one of the leaders started to speak from a prepared text, Trudeau said, "If you're going to read a speech, put it in the mail."

There were some around the Sheraton Hotel's vast round conference table with a garden of mums in the middle who found the Canadian's style a bit alienating, but eventually it was accepted and became almost contagious.

"Very provocative," a Venezuelan participant called it. "Very good."

When a few minutes into the first afternoon session Chinese Premier Zhao Ziyang flipped on the light indicating that he wanted to speak, a sort of hush fell over the assembled dignitaries, surprised that even the reserved Peking leadership was leaping into the fray.

DOWN THE ROAD a mile or so, speculation was rampant among the 2,000 reporters at the international press center that President Reagan would never be able to hold his own with his isolated advocacy of free markets and his oft-remarked lack of background on international issues.

But, apparently almost surprising his own Cabinet members, Reagan stayed in the middle of the debate.

"The most striking thing was the participation of the United States," Treasury Secretary Donald Regan told a press conference in a tone that unintentionally provoked a wave of laughter.

"It was clear that he Reagan had done his homework," Secretary of State Alexander M. Haig Jr. said later, again raising some eyebrows among reporters who wondered why that needed saying.

By Friday morning, however, even members of the Algerian delegation -- some of Reagan's most implacable critics in the debate -- said the U.S. president held up well, and the Americans found that instead of being bushwhacked by an irate South as some of Reagan's advisers expected, Reagan was merely being nudged and prodded with facts and cordial conversation.

"Nobody attacked him. Nobody cornered him," said one source close to the Yugoslav delegation. "They just said, 'Mr. President, what you want doesn't work.' "

Because everyone stayed in the same building, there was not much room for stuffiness. Leaders constantly were bumping into each other in the halls between conference sessions and the wide array of more formal bilateral meetings. They and the senior members of their delegations stood around chatting over coffee during breaks in the sessions or strolled on the beach just outside the conference room.

By the time they all turned out on the sand for a group portrait Friday morning, with Reagan seated at the group's extreme right, several of the dignitaries looked relaxed to the point of sleeping.

For the convivial gathering of presidents, prime ministers and foreign ministers the final trial came on Friday afternoon: the debate on whether, when and how to start global negotiations for something like a new world economic order.

"People who think the South came here looking for negotiations on a lot of concrete issues have it all wrong," a member of the Venezuelan delegation said afterward. "We came for nothing more than to hear the Americans say 'yes.' "

But America's initial position on global negotiations suggested, as a low-ranking U.S. official said privately, that "we support them as long as they don't get results."

THE LEADERS from the South, meanwhile, although heads of their own countries, shared a common feeling that they were representing more than their own people. Many, particularly the Algerians, were acutely aware that they would leave Cancun for the United Nations and the mass of developing countries represented there in the Group of 77 would hold them accountable for whatever they did at the summit.

"There was an extraordinary sensitivity on the part of a lot of them as to why they were in Cancun at all," MacGuigan said. "They feel they have to go back and justify to that group why they're even here, let alone what they're agreeing to."

So the developing nations pressed for more talks at the United Nations, where more Third World countries would be represented.

The Canadians presented a draft summary of the meeting that would have moved ahead with informal talks on a number of specific subjects, but not at the United Nations. The South would have none of it. So Trudeau extended the break before the final session by an hour.

Leaders huddled in caucuses as the Venezuelans worked on some alternative phrasing. Finally, by about 6 o'clock when the final session was to start, vague wording had been worked out that essentially sacrificed the who, what, when and how of preliminary negotiations in order to be clear about where: the United Nations, of course.

No one knew if Reagan would go for it, but as he walked into the conference room Venezuelan President Luis Herrera Campins drew him aside and they started chatting privately. Reagan said the basic wording was okay with him, according to members of various delegations, and within minutes the summary was complete.

Exhaustion triumphed, and the summit broke up with, in the words of one participant, "a great sense of relief."