Pope John Paul II wound up an emotional eight-day pilgrimage to his native Poland today with a private meeting with Lech Walesa, leader of the outlawed Solidarity trade union, and a conciliatory gesture to the country's Communist authorities.

An hour after the pope left Poland, a senior aide to Polish leader Gen. Wojciech Jaruzelski said in a television interview with the British Broadcasting Corp. that as one result of John Paul's visit, martial law may be abolished July 22, Poland's National Day, Reuter reported from London. The statement was made by Maj. Wieslaw Gornicki, Jaruzelski's personal adviser.

The long-awaited meeting with Walesa took place late this morning near the holiday resort town of Zakopane in the foothills of the high Tatra Mountains, where the pope liked to hike and climb as a youth. Vatican spokesman Romeo Panciroli told reporters that Walesa was accompanied by his wife Danuta and four of their seven children.

The only previous meeting between the two men took place in Rome in January 1981--when the pontiff granted an audience to a Solidarity delegation--11 months before the imposition of martial law in Poland. During a speech earlier this week, the pope pointedly referred to this encounter, saying that the Solidarity delegation had been accompanied by a Polish diplomat. He also made clear that he supports the ideals of the labor movement Walesa led.

At the farewell ceremony at the Krakow airport, the pope appeared eager to lessen the friction his visit has created with Poland's military authorities. He chatted animatedly with Poland's titular head of state, Henryk Jablonski, and used soothing, noncontroversial language in his final address.

Another welcome gesture, from the government's point of view, was the unscheduled meeting last night between the pope and Gen. Jaruzelski in Krakow's royal Wawel Castle. At a press conference in Warsaw today, government spokesman Jerzy Urban said that the meeting, which lasted an hour and 37 minutes, could be regarded as "an indirect response to various speculations" and "evidence of the interest of these two leaders in pursuing a direct dialogue."

Polish officials have bitterly attacked western press coverage of the visit for "misinterpreting" the pope's outspoken remarks about respect for human rights and national freedom as an attack on the Jaruzelski government. They also have suggested privately that Jaruzelski is under pressure from hard-liners within the Communist Party who are unhappy with his relatively liberal line toward the Roman Catholic Church and his failure to stamp out political opposition in Poland.

Urban's comments indicated that the government is putting the best face it can on the visit despite earlier concern about "political demonstrations" during and after the vast open-air masses presided over by the pope.

The spokesman said he hoped the visit would inaugurate "several positive changes in our policy" and "accelerate the favorable evolution of the situation." Among the measures the government is believed to be contemplating are amnesty for political prisoners and the full lifting of martial law.

Urban said the authorities were willing to consult with the Roman Catholic Church and individual groups of workers, but not with Solidarity, which he described as "an organization which does not exist anymore and belongs to the past." He said, "There will be no dialogue with the opponents of socialism, with Solidarity's former leadership, or with the underground."

The pope emerged from last night's meeting with Jaruzelski in a happy, relaxed mood. After being driven back to his residence in Krakow's Old Town, he stayed up until nearly midnight singing and joking with young people gathered outside.

"Father, save Poland" and "We trust you," they chanted in slogans symptomatic of the emotional enthusiasm that has been released by this pilgrimage.

At breakfast this morning with editors of Tygodnik Powszechny, an independent Catholic weekly, the pope was reported to have asked how the 21 speeches and sermons he delivered during the pilgrimage had been received. He was said to have seemed pleased when he was told that he had more than fulfilled everybody's expectations.

He then flew in a convoy of three white helicopters to the mountains of southern Poland, which rise up along the border with Czechoslovakia. His meeting with Walesa took place in a heavily guarded rest home in the Chocholowska Valley outside Zakopane.

Security precautions were so strict that local villagers said that even the regular staff members at the rest house were being refused admittance. Reporters who tried to reach the area were turned away by police, but were able to see the pope's helicopter arriving and leaving.

Walesa, who had been taken to the appointment under government escort in a special plane, was flown back to his home town of Gdansk on the Baltic coast this afternoon. A spokesman at his home said he would not be commenting on the meeting until Friday.

After spending about four hours in the mountains, the pope was flown by helicopter to the Krakow airport for farewell ceremonies before his departure for Rome aboard a Soviet-built Ilyushin 62 belonging to the Polish airline LOT.

In his farewell speech, Jablonski said the pope had an opportunity to examine directly "the complexity of Polish problems." Jablonski again defended the government's commitment to carrying out economic reforms.

In a carefully balanced reply, the pope said the "dignity and rights" of man are closely connected with his "duties and responsibilities."

"On bidding farewell to my compatriots in Krakow, the city which has seen the difficult moments of the country but has also witnessed the periods of its greatest triumphs, I wish that . . . good will once again prove stronger than evil on Polish soil," he said. "I always pray for this."