President Reagan, concluding the first state visit of his administration, today won praise and applause from Canadian leaders who had sharply criticized his policies a week ago.

Reagan and Secretary of State Alexander M. Haig Jr. appeared to have largely succeeded in a principal objective of calming Canadian fears that U.S. military aid to El Salvador would lead to a Vietnam-type involvement.

"On El Salvador in particular there was agreement, as I could sense it, that the solution there should be a political one and that we would work in whatever way we could to ensure that the moderates were those who took over and not the extremists of the right or of the left," said Prime Minister Pierre Trudeau, who originally had called sending U.S. arms to the government in El Salvador "a mistake."

Secretary of State for External Affairs Mark MacGuigan Canadian counterpart, said this meant that Canada, too, would support the Salvadoran government of Jose Napoleon Duarte as "probably the most feasible channel through which the people of El Salvador can realize Democracy."

While MacGuigan said that Canada had not retracted its basic view opposing any arms sales to El Salvador, he referred to the present flow of U.S. arms as "modest" and not aimed at a military buildup.

"There was no difference between the positions of our two governments, and indeed, there was no emphasis in American thought and planning on a military solution," MacGuigan said. "So, the arms flow which is occuring, which they [the Americans] apparently intend to balance out the arms that have already been received by the rebels from outside, . . . is not a harbinger of a massive U.S. military involvement in El Salvador."

Earlier, MacGuigan praised Reagan for displaying graciousness, wit and an understanding of Canadian problems.

"I'm not aware of any president since Franklin Roosevelt who had a similar determination to get along with Canada," MacGuigan said.

Trudeau, assessing the visit for reporters, lauded Reagan and his aides for exhibiting "the best possible of spirits and attitudes."

After dinner with Reagan Monday night, Trudeau said he and the president had got along well together.

"I think we're both a bit of a ham," Trudeau said. "He's a good actor and 'i'm a bad one." tIn addition to the near-agreement on El Salvador, Reagan and Haig won support for U.S. opposition to an early summit with the Soviet Union. Soviet President Leonid Brezhnev has issued the invitation for a summit in letters to the governments of the United States, Canada and various European nations.

Macguigan said it would not serve the cause of world peace "to rush into a summit in which there was an unstated or unsettled situation with respect to Poland." A summit should be held at "the appropriate time," he said, but "we're happy to let the American administration judge what is the appropriate time."

Reagan, declaring that the United States has "no better friend than Canada," was interrupted repeatedly by applause when he addressed the House of Commons this morning. The applause was particularly warm when Reagan promised to honor commitments made by President Carter to continue cleanup of the Great Lakes, carry out compacts to "control the air and water pollution that respects no borders" and participate in the building of a pipeline that will carry natural gas from Alaska across Canada to the upper Middle West.

While his speech focused on domestic issues and the long-standing neighborliness between the United States and Canada. Reagan also used the occasion to once again take a tough line against "Soviet adventurism" and undermining of governments friendly to the United States.

"On this side of the Atlantic, we must stand together for the integrity of our hemisphere . . . for the inviolability of its nations, for its defense against imported terrorism, and for the rights of all our citizens to be free from the provocations triggered from outside our sphere for malevolent purposes," Reagan said.

One issue Reagan omitted from his speech that was included in the prepared text was a now-discarded fisheries treaty that would have regulated the share of scallops divided by U.S. and Canadian fishermen off the coast of Maine and Nova Scotia. Trudeau said there was "a deep disappointment" in Canada that this treaty had been withdrawn but he did not dispute Reagan's contention that it was impossible to win ratification of it in the U.S. Senate.

Trudeau said the two leaders had assured each other that there would not be no "fish war" on the George's Bank, which now stands open to virtually unregulated fishing.

"No one would benefit if the fish ultimately were fished out by the extraordinary capacities of the Canadian fishermen to go ahead and fish if they see that there are no limits," Trudeau said.

Another potential disappointment for Canada, though it was not mentioned prominently today, was the pending Reagan budget cut proposals that would reduce funds available for air pollution control. Conservative members of Parliament cheered Reagan's recounting of his economic program and the need to cut the budget and control inflation, while Liberal membes sat silently through this portion of the speech.

John Roberts, the Canadian minister of the environment, said he was pleased that Reagan had committed himself to a compact signed by Carter last August in which both nations pledged to monitor the impact of air pollution and acid rain.

But Roberts warns that the first results of this monitoring show a pronounced increase in the effects of acid rainfall, which he predicted in time could destroy most of Canada's 4,000 lakes as it has destroyed many lakes in Scandinavia.

Roberts expressed concern that American industry, in a government-encouraged rush to coal conversion, might not use the technology necessary to protect the environment.

"It's hard for us to understand why we should accept the garbage thrown over a neighbor's fence so that the Eastern Seaboard can have even cheaper energy," Roberts said.

Canadian and U.S. officials signed two noncontroversial agreements during Reagan's visit. One renews the North American Aerospace Defense Command (NORAD) agreement providing for joint defense of the two countries for five more years. The other allows workers in both countries to earn Social Security benefits in either nation.