The Jewish community had challenged the ban, introduced in 2013, saying that it was discriminatory.
The Constitutional Court had previously ruled that it was against Polish law to allow animals to be killed without first being stunned.
But to produce kosher and halal meat, animals must be uninjured before death.
The ban had been challenged by the Union of Jewish Religious Communities on the grounds that it impacted on their constitutional right to practise their religion and prevented minority communities from following their traditions.
The court ruled that the ritual slaughter of animals should be allowed on the grounds of religious freedom.
The ritual slaughter of animals had been practised in Poland for centuries by both Jews and Muslims, the court's judge said.
Under Jewish and Islamic law, animals must be healthy and uninjured at the time of death, which usually rules out normal stunning methods that involve electrocution or shooting the animal with a metal bolt.
Animals are traditionally slaughtered with a single, rapid cut to the throat in Muslim and Jewish communities.
Before the ban, Poland had been a major exporter of kosher and halal meat and poultry to the Middle East.
The reversal of the ban also allows for a resumption of exports, Jewish leaders say.
Animal rights groups had welcomed the ban, saying the practice caused animals unnecessary suffering.
Israel, however, criticised it, noting that the Nazis had done the same thing during their occupation of Poland during World War Two.
A Polish court has ruled that a ban on the ritual slaughter of animals for the needs of the Jewish community is unconstitutional.