The government-controlled constitutional court said terminating pregnancies because of foetal defects was unconstitutional.
Angry protesters gathered on Thursday outside the ruling right-wing party offices in Warsaw and the home of its leader, Jaroslaw Kaczynski, in defiance of a ban on public gatherings amid the coronavirus pandemic.
The court’s decision means banning the most common reason for ending a pregnancy in the largely Catholic country, and it pushes Poland further away from the European mainstream, as the only EU country apart from tiny Malta to severely restrict access to abortion.
Government figures for last year show that most of the 1,110 legal abortions performed last year were due to foetal genetic defects such as Down's syndrome or to physical defects.
Warsaw police said 14 people were in custody and 35 had been fined for having broken the ban on gatherings. Small protests also took place in the cities of Krakow, Lodz and Szczecin.
"It's sick that such controversial things are being decided at a time when the entire society lives in fear (of the pandemic) and is afraid to go into the streets," said Marianna Dobkowska, 41.
Activists are also planning more protests in various cities this weekend.
Prime minister Mateusz Morawiecki on Friday announced the closure of restaurants and bars for two weeks and a limit on public gatherings to five people, after new coronavirus infections hit a daily record of more than 13,600.
"Our actions must be much more decisive," Morawiecki said.
Conservative values have played a growing role in public life in Poland since the nationalist Law and Justice (PiS) party came into power five years ago.
Curbing access to abortion has been a long-standing ambition of the party, but it has stepped back from previous proposals after widespread public backlash.
Women's rights and opposition groups reacted with dismay.
"It is a devastating sentence that will destroy the lives of many women and many families," said lawyer Kamila Ferenc, who works with an organisation helping women denied abortion.
"It will especially force the poor to give birth to children against their will. Either they have no chance of surviving, or they have no chance of an independent existence, or they will die shortly after giving birth."
Council of Europe commissioner for human rights Dunja Mijatovic called it a "sad day for women's rights".
"Removing the basis for almost all legal abortions in Poland amounts to a ban and violates human rights. Today's ruling means underground or abroad abortions for those who can afford and even greater ordeal for all others."
But Kaja Godek, a member of the Stop Abortion group, said: "Today Poland is an example for Europe, it's an example for the world."
Maria Kurowska, of United Poland, a party in the ruling coalition, said they were pleased with the ruling “because one cannot kill a child for being sick. This is not a foetus, it is a child".
Abortion rights activists say access to the procedure was often declined in recent years in Poland. Many doctors exercise their legal right to refuse on religious grounds.