Crowds chanting Solidarity slogans clashed with police in several Polish cities today as the nation tensely marked the third anniversary of the birth of the once-independent Solidarity trade union.

In the industrial town of Nowa Huta near Krakow, where the battling appeared most serious, an estimated 10,000 workers from the steel works, Poland's largest enterprise, tried to march from the factory gates into town and were dispersed by riot police firing tear gas, concussion grenades and water cannon.

In the northern port of Gdansk, where shipyard workers went on strike three years ago to win the right to form free trade unions, military police dressed in battle fatigues and waving hard rubber truncheons charged into a stream of about 6,000 to 10,000 demonstrators who were leaving an evening Roman Catholic mass showing "V for victory" signs and shouting "Solidarity."

Earlier in the day, security forces staged a massive show of force around this port town to head off possible protest action and contain a throng of about 1,500 led by Solidarity founder Lech Walesa as it surged out of the Lenin Shipyard to the nearby St. Brigid's Church crying "Solidarity" and "Walesa."

A skirmish line of helmeted police prevented the marchers from returning with Walesa to the monument outside the shipyard, erected by Solidarity in memory of workers killed by police during 1970 protests. Walesa later was permitted to pass through the cordon to lay flowers at the monument.

In Warsaw, workers heeding a Solidarity underground call to boycott public transport during the afternoon rush hour massed along Marszalkowska, a central artery and main tram street. As a group of about 2,000 tried to march, it was firmly steered into side streets and dispersed by riot police backed by intimidating convoys of trucks and vans.

A gathering of several hundred people in the southwestern city of Wroclaw, a former Solidarity stronghold, also reportedly was broken up by police using tear gas as it attempted to march toward the grave of a young worker shot by police during demonstrations last Aug. 31.

Except in Nowa Huta, where the fighting was said to have lasted several hours, today's clashes were considerably scaled down from those of a year ago, when demonstrators waged pitched battles with police in numerous cities and five protesters died. The atmosphere across much of Poland today was tense but most places were reported calm.

Confronted with tough new post-martial law rules that provide for three-year jail terms for participating in protests, Poles appeared to be shying away from head-on fights with police. A year and a half of demonstrations on major anniversaries has not softened the regime of Gen. Wojciech Jaruzelski, and Solidarity's underground leadership has itself begun to counsel Poles to prepare for a long-term political struggle.

But there remains for the opposition the problem of what to do on anniversaries like today, which recalls the signing of the 1980 worker-state accord that opened the way for Solidarity.

"Last year, people thought they could do something," said a Western diplomat in Gdansk today. "This year, they knew they were beat on the streets."

Walesa himself sought to avoid a sustained demonstration because of worry about new arrests.

"That's enough for today," he shouted to the adoring crowd that followed him from the shipyard to St. Brigid's Church. "We've shown a great success. We've proved that we exist. Now, please, really go home quietly so we can win tomorrow."

The boycotts of public transport and of official newspapers called for today by Solidarity's underground leadership seemed to have mixed results. Trams and buses in Gdansk and Warsaw were less jammed than usual during the 2 to 4 p.m. boycott period, but a number were still crowded with passengers.

Communist authorities had ridiculed the boycott appeals, appearing to be not much concerned about them. Referring to the transport boycott, Deputy Prime Minister Mieczyslaw Rakowski told workers in the Lenin Shipyard last week that a walk in Poland's sunny late-summer weather would be good for them.

Officials had warned against protests today, making it known that security forces would maintain and order. Moreover, a major propaganda drive anticipating today's anniversary has portrayed the Jaruzelski regime as living up to the spirit and letter of the August 1980 agreements signed with workers at Gdansk, Szczecin and Jastrzebie.

The trouble in Nowa Huta began as workers poured out of the huge steel plant there after the morning shift. Ignoring public buses and trams, they marched toward the Church of Our Lady near the center of town.

Polish television said tonight that the group "acted in a provocative way," forcing the police to rush against it.

Official sources reported scores of people detained in Nowa Huta, and church sources there said injured demonstrators, some splattered with blood, were being treated at the town's central Catholic church. They said fighting had flared in the streets outside the church in the afternoon while a mass was underway.

In Gdansk, police tightly controlled access to the towering shipyard monument, a focal point for protests. Walesa was denied permission to place flowers there at 2:30 p.m., when the shifts changed. He was allowed to pay his tribute at 4 p.m., but by then the police had closed off the area to all but those carrying flowers to the monument.