Lech Walesa Thursday called the agreement with authorities to legalize Solidarity a victory, but he said the nation must work hard to take advantage of the chance the pact offers.

Solidarity adviser Tadeusz Mazowiecki said the free trade union movement, banned for seven years, could be formally registered in court within two weeks. The agreement allows Solidarity to organize.Walesa, the leader of Solidarity, and the interior minister, Gen. Czeslaw Kiszczak, approved the agreement Wednesday. It reinstates Solidarity and will give Poland its first free elections since the postwar communist takeover.

The current one-house parliament, the Sejm, meets Friday to enact the agreements into law.

Walesa told a news conference at Warsaw University that Solidarity must now organize the nation's provincial governors and city mayors. He said the agreement was a political victory, "a theoretical one which may turn out to be a victory or a disaster if we are not able to make use of it."

Walesa appeared unconcerned by the lack of reaction by Poles to the restoration of the Soviet bloc's first independent trade union, which claimed 10 million members and ignited that nation's spirit during its 16-month legal existence in 1980-81.

He said he expected Solidarity to attract 5 million to 7 million members. He said he would like to see at least three competing trade unions.

The agreement, under which the union is to work with authorities to revive Poland's crumbling economy, came after two months of intensive talks. The pact also reinstates independent student, farmer and artistic organizations banned with Solidarity after a December 1981 military crackdown.

Under the accords, free elections are to be held in June for a parliament that communist authorities will still control but in which the opposition will have strong representation.

In Moscow Thursday, the official Tass news agency reported only that the talks had ended and that Walesa had participated in them.

Radio Moscow's English-language service reported on the legalization of trade unions and establishment of a two-chamber parliament but made no mention of the free elections.

A series of strikes last spring and summer and Poland's crippled economy prompted authorities to agree to the talks that produced the accords Walesa and Kiszczak signed Wednesday.