Ownership of the papers had been in dispute after the Israeli National Library claimed them, over the wishes of two sisters who had inherited the vast collection of rare documents from their mother and insisted on keeping them.
Friday's ruling by the Tel Aviv District Family Court ordered the collection to be transferred to the library in Jerusalem, which had argued that Max Brod, Kafka's close friend, had bequeathed the manuscripts to the library in his will.
The two sisters, Eva Hoffe and Ruth Wiesler, had inherited the documents from their mother, Brod's secretary, and had been storing them in a Tel Aviv apartment and bank vaults.
Kafka, a Jewish Prague native who wrote in German, is known for his dark tales of everyman protagonists crushed by mysterious authorities or twisted by unknown shames. His works have become classics, like "The Metamorphosis," in which a salesman wakes up transformed into a giant insect, and "The Trial," where a bank clerk is put through an excruciating trial without ever being told the charges against him.
The trove is said to include Brod's personal diary and some of Kafka's writings, including correspondence the two kept with other notable writers, which could shed new light on one of literature's most influential figures.
The German Literary Archive was not part of the legal proceedings but had backed the sisters' claims, hoping to purchase the manuscripts and arguing that they belong in Germany.
Ulrich Raulff, who heads the archive, said the papers have drawn great interest because they will likely reveal much about the years in Kafka's life that the public knows very little about.
"I hope that the Israeli National Library will provide open access to the material for the public as soon as possible," he said. "Researchers have been waiting for the material with excitement for years already."
Kafka gave his writings to Brod shortly before his own death from tuberculosis in 1924, instructing his friend to burn everything unread. But Brod instead published most of the material, including the novels "The Trial," "The Castle" and "Amerika."
Aviad Stollman, Judaica Collections Curator at the National Library, said that the majority of the manuscripts are by Brod not Kafka, but that they contained tremendous research and sentimental value.
"For decades these manuscripts were hidden and now we can display and preserve them under proper conditions," he told Israel's Channel 2 TV.
"There are 40 thousand pages, a tremendous amount," he added. "Whoever loves Kafka will be able to see his signature and notes and crossings outs ... We hope the material will be on the library's website soon."
Despite the ruling, Hoffe will be entitled for royalties from any future publication of the documents.
Professor Otto Dov Kulka, a self-described Kafkaphile and retired professor of history at Israel's Hebrew University, supported the court decision.
"The National library has taken care of Einstein's theory of relativity, and we will now take care of the great works of Kafka," he said.
Associated Press writer Juergen Baetz contributed to this report from Berlin.