President Reagan wound up a 10-day European tour today extolling the virtues of democracy to Portugal's parliament while his top aides tried to put the best face on a trip that has been marked with difficulties.

"You believe, as we do, that freedom works," Reagan said in a speech that was preceded by a quiet walkout by 35 Communist members of the 250-member Assembly of the Republic.

Later, Secretary of State George P. Shultz said the Reagan journey was a "trip of great importance" that dealt with "issues of historic proportions and enduring significance." White House chief of staff Donald T. Regan said the trip had demonstrated that "Reagan is now the leader of the free world."

Reagan is to fly home Friday after a news conference here.

Both Shultz and Regan volunteered their assessments to reporters in an effort to give a favorable cast to a trip during which Reagan was the target of hecklers in the European Parliament at Strasbourg, France, and sizable street demonstrations in Spain against the presence of U.S. bases and during which he was the focus of a controversy over the laying of a wreath at a German military cemetery.

Regan said the president could have sidestepped these controversies but to do so would have been "to take the easy way out."

In an interview here, the White House chief of staff also suggested that the president and Soviet leader Mikhail Gorbachev, in major speeches yesterday, were both pursuing similar strategies of alternately staking out hard-line positions against each other's policies while at the same time indicating a willingness to resolve their differences at a summit meeting.

"Notice the parallelism here," Regan said of Gorbachev, who addressed a Kremlin rally yesterday commemorating the 40th anniversary of the defeat of Nazi Germany. "He's talking tough, certainly," Regan said of the Soviet leader, who charged that the United States was "the forward edge of the war menace to mankind."

"He's staking out positions," Regan said of Gorbachev. "He didn't get his job because he's a cream puff." The president, in his speech yesterday before the European Parliament, also was critical of Soviet actions. But both leaders had conciliatory passages in their addresses and in an exchange of letters marking the 40th anniversary of the end of World War II in Europe.

Eventually, said Regan, "there probably will be a summit" meeting of the two leaders.

Administration sources have speculated that a meeting between Reagan and Gorbachev, if it occurs, will take place this September or October at the United Nations.

On another subject, Regan told reporters that the administration would make another attempt to win congressional approval of $14 million in "humanitarian aid" for the rebels opposing the Nicaraguan government, and the White House still believes the best way of providing these funds is through the CIA.

In his speech today, Reagan acknowledged the problems that Portugal has experienced since becoming a democracy in 1976, but he urged the assembly to look ahead.

"History shows a strong, unbreakable link between political freedom and economic growth, between democracy and social progress," Reagan said.

"In a sense, then, Karl Marx was right," he added. "Economic progress is leading to clashes with old entrenched political orders. But Marx was wrong about where all this would occur, for it is the democratic world that is flexible, vibrant and growing -- bringing its peoples higher and higher standards of living even as freedom grows and deepens.

"It is in the collectivist world that economies stagnate, that technology is lagging and that the people are oppressed and unhappy with their lives," he said.

Before the walkout, one member of the legislature, Antonio Gonzalez, the lone member of the Green Party, brought a white dove to his bench. A White House advance man walked up to the bird in an apparent attempt to remove it, sparking shouts and boos from surrounding leftist members. A few minutes later, the dove was removed without protest by a uniformed Portuguese official.

The Communist delegates silently walked out just before the speech, filing single file in front of the president to make their point, a subdued contrast to heckling in the European Parliament yesterday.

"I'm sorry that some of the chairs on the left seem to be uncomfortable," Reagan quipped as he stepped to the microphone.

Earlier today, the president met with Portugese Prime Minister Mario Soares, and officials on both sides said there were few disagreements.

The leaders muted any differences over Nicaragua, although Portuguese officials said their government would not back Reagan's economic sanctions against Nicaragua, according to Foreign Minister Jaime Gama. But White House spokesman Larry Speakes said the Soares government remains in agreement with the administration's "goals" in Central America.

Gama said after meeting Shultz that he had given the secretary of state a memo seeking relaxed trade barriers on Portuguese goods. Gama said he also "insisted" on the need for greater financial compensation from the United States in return for the use of the Lajes military base in the Azores.

As Reagan's trip neared an end, his principal advisers vied with one another to praise the results of the journey despite what Regan acknowledged had been "a few glitches."

Regan and deputy chief of staff Michael K. Deaver said Americans now approve of the controversial wreath-laying at West Germany's Bitburg cemetery, where 49 SS soldiers are buried. Deaver said that a survey taken this week by Reagan pollster Richard B. Wirthlin showed a 58 percent to 22 percent margin in favor of Reagan's action.