Lech Walesa, the leader of Poland's outlawed Solidarity union, held more than two hours of talks here today with the Roman Catholic primate of Poland, Archbishop Jozef Glemp.

The meeting, at the primate's residence in Warsaw, was the first between the two since the imposition of martial law last December and Walesa's 11-month internment. The Solidarity leader, who was released from detention a week ago, drove to Warsaw from Gdansk for the meeting in the company of his parish priest, the Rev. Henryk Jankowski, and a legal adviser.

Neither Walesa nor church officials would comment on the meeting. A reliable source said Glemp had been invited to meet with the minister of religious affairs, Adam Lopatka, afterward, presumably to brief the martial-law authorities on his talk with Walesa.

A meeting between Glemp and Walesa, a devout Catholic who relied on the church for advice during the 16 months of Solidarity's legal activity, had been expected. But some observers speculated that the timing could be connected with allegations contained in a report carried by NBC that security officials had shown senior church officials videotapes of Walesa in "sexually compromising" situations.

Church spokesmen formally have denied the story and, despite intensive inquiries, no other Western news organization in Warsaw has found reliable evidence to support it. Advisers to Walesa, however, are known to be anxious to avoid the impression of a rift between him and the church, which is regarded by many Poles as the most important independent institution left now that Solidarity has been suppressed.

Today's meeting is therefore being interpreted in part as an attempt to demonstrate that Walesa still enjoys the confidence of the church. As in the days before his internment, Walesa was wearing a badge of the Black Madonna, Poland's most revered religious icon, on his lapel.

Since his release a week ago, Walesa has stayed at home in a suburb of Gdansk and -- apart from a meeting with the local bishop on Thursday -- this was his first important outside engagement. He spoke to foreign correspondents at his home on Monday, but has refused to make public statements since then.

After the meeting with Glemp, Walesa was driven to the offices of the Polish bishops' conference. But the bishop he was to meet there had left by the time Walesa arrived.

Leading a convoy of foreign correspondents through the streets of Warsaw, the Solidarity leader was then driven to the apartment of his legal adviser, Wladyslaw Sila-Nowicki. On emerging from the apartment, he was greeted by a crowd of about 50 amazed passers-by who shouted out his name and asked him to speak to them.

Holding his fists in the air, as he used to during Solidarity's heyday, Walesa replied enigmatically, "It's good, but it will be better."

He then drove back to Gdansk.

Walesa is forced to be circumspect in his public statements both because martial law forbids the conduct of union activity and because he is still catching up with events in Poland during his detention. But he has made clear that he still believes he has a significant political role to play and that, when the time is right, he will speak out in public.