At least 15,000 pro-Solidarity demonstrators marched peacefully through the streets of Warsaw for two hours today in the largest and most successful attempt at countering Poland's official May Day celebrations since such counterdemonstrations began three years ago.

But in Gdansk, the northern port city where the now-banned Solidarity trade union movement was born, tensions exploded as more than 2,000 stone-throwing protesters, many of them youths, battled for an hour with riot police using tear gas and water cannons.

The size and intensity of today's demonstrations surpassed those of the past two years, clearly indicating that, despite official declarations to the contrary, strong support still exists for the Solidarity movement.

The protests were seen as a new embarrassment to the rule of party leader Wojciech Jaruzelski, who just met with Soviet leader Mikhail Gorbachev four days ago. Gen. Jaruzelski was given the Kremlin's public support for what was described as Poland's achievement in "fully overcoming the effects of the crisis" posed by Solidarity, "for stability and for strengthening the position of socialism."

U.S. television correspondents who witnessed the fighting in Gdansk, which broke out near Solidarity's former headquarters there, said a militiaman was beaten by demonstrators. A protester seen tossing stones at a police vehicle was said by the sources to have been badly injured by police, who reportedly rammed the protester with a van, jumped out and clubbed him senseless before sending him to a hospital.

Another group of about 400 demonstrators in Gdansk gate-crashed the official ceremony, sitting down on the parade's route to slow it. They were removed forcibly by militiamen.

Lech Walesa, who was chairman of Solidarity when it was crushed by martial law in 1981, was prevented from joining the communist-sponsored rally in Gdansk, his home town. He and about 200 followers walking from his apartment on the city's outskirts were blocked about a mile from the official march by combat-ready police, who formed a cordon around the opposition figure and escorted him back to his home.

Clashes between police and demonstrators also were reported in Poznan, and numerous detentions were said to have occurred outside the huge Nowa Huta steelworks near Krakow, traditionally the scene of antigovernment demonstrations.

On a day in which Warsaw police otherwise showed restraint, two leading opposition figures -- Jacek Kuron, a veteran dissident, and Seweryn Jaworski, former deputy Solidarity chief for the Warsaw region, were taken into custody.

The two were picked up after negotiating a settlement with the police that secured an end to the Warsaw march, sparing other arrests and potential violence in the capital. Government spokesman Jerzy Urban told reporters that Kuron and Jaworski were being held in connection with their possible role in organizing the Warsaw demonstrations and that a government prosecutor would determine whether to press charges.

Rain and snow in some parts of the country reduced the expected turnout at official parades in some cities. The official Polish press agency PAP said 7 million joined in the state-organized pageants, about 1 million less than officially reported last year.

Communist authorities have looked on the May Day turnout as a kind of referendum of support for the government, although parade ranks tend to be swollen by many whose attendance is made obligatory.

Since the suppression of Solidarity, the Polish underground has called for independent marches on May 1 to embarrass the government and advertise political grievances.

Urban claimed that opposition plans to upstage, disrupt and boycott the official celebrations had failed. But Solidarity activists declared the day a victory, especially in Warsaw, where few had expected to see so large a protest march.

Solidarity supporters met for mass at St. Stanislaw Kostka Church, which has become an opposition shrine since the murder last fall of one of its priests, the Rev. Jerzy Popieluszko, a Solidarity chaplain.

A sermon by the Rev. Jan Sikorski, closely tied to a church aid program for political prisoners, recalled the worker-government accords that gave rise to Solidarity and quoted from the codes of the International Labor Organization endorsing the right of workers to form the labor groups they want.

Washington Post correspondent Celestine Bohlen added from Moscow:

At the first May 1 celebration presided over by Soviet leader Mikhail Gorbachev, in contrast to past ones, there was only a modest tribute paid to the leader, with few portraits and no quotations from his speeches among the posters.

Despite pouring rain and cool weather, tens of thousands of citizens filed past the Soviet leadership and dignitaries.

In the diplomatic section, Ronald P. Reagan, the president's son, in Moscow on a personal visit, watched the 1 1/2-hour parade, which he described as "very long, and very big."