Thousands of riot police took up positions on the streets of Warsaw and other Polish cities today in an attempt to prevent nationwide protest demonstrations planned for Tuesday by the suspended Solidarity trade union movement.

An official communique issued tonight reminded Poles that all public gatherings are banned under martial-law regulations and that participants would be severely punished. The rallies were called to mark the second anniversary of the Gdansk agreement that recognized free unions for the first time in a Communist country and initiated a 16-month experiment in democracy that was crushed last December.

Tuesday's demonstrations are regarded by many observers here as the most important test of wills between Solidarity supporters and the government since the military takeover. The credibility of both sides is at stake with the military government in effect accepting a challenge from the Solidarity underground to be decided on the streets.

With the government possessing superior organizational ability, weapons, and communications, Solidarity's only strength lies in its power to mobilize large numbers of people. A poor turnout could be a fatal blow to the underground and, as Solidarity leaders themselves acknowledge, it would probably mean an end to the union's hopes of organizing mass protests in the future.

Tonight, a police spokesman went on television to accuse Solidarity activists of planning to attack the security forces. Viewers were shown pictures of sharpened rods, clubs, chains, chemicals, equipment for molotov cocktails, cartridges, and nails that had allegedly been confiscated from hideouts in Warsaw and the central city of Lodz.

The spokesman, Maj. Jerzy Lipinski, said the Solidarity underground had also organized first aid posts in churches and hospitals -- a sign that victims were expected. "Groups of adventurers," he said, were planning to provoke clashes between the security forces and demonstrators.

Thousands of leaflets were distributed in Warsaw today calling on Solidarity members to gather at four central squares at 4 p.m. The leaflets, which were signed by Zbigniew Bujak, the head of the union's Warsaw chapter who is in hiding, said the rallies would end peacefully at 6 p.m. with commemorative services in selected churches.

A police spokesman said tonight that equipment belonging to the clandestine station, Radio Solidarity, had been seized by police earlier today. The radio went on the air yesterday to appeal to police not to arrest demonstrators -- but a broadcast planned for tonight did not take place.

Heightened security measures visible in Warsaw have included the stationing of dozens of police trucks, water cannons, and even armored personnel carriers at points where demonstrations are expected. Foot patrols of riot police and soldiers have been stepped up.

The government's efforts to keep people off the streets have included the scheduling of a television program for precisely 4 p.m. Tuesday of highlights from last month's World Cup soccer competition in Spain. Poland did unexpectedly well in the competition, winning third place, so normally such a program would be a powerful incentive for staying home. During the last major round of street disturbances in May, the American movie "Easy Rider" was shown for the first time on television.

In another precaution, sales of alcohol have been restricted throughout the country for the next three days.

In addition to Warsaw, potential trouble spots could include the cities of Wroclaw, Krakow, and Gdansk, all former Solidarity strongholds. Privately officials said they were worried about the situation in Szczecin, the northwestern port city that was one of the focal points of labor unrest in August 1980.

Today was the anniversary of the labor agreement in Szczecin that was signed one day earlier than that of Gdansk but away from the glare of international publicity. Television news tonight carried pictures of the signing ceremony.

An official ceremony at the Warksi shipyard in Szczecin, the site of the 1980 negotiations, to mark the anniversary passed peacefully.