The court said that Amsterdam's Anne Frank House had until the end of the year to return the extensive family archives, including letters and photos, on loan from the Anne Frank Fonds Basel.
The court also ordered the Anne Frank House to pay the legal costs of the foundation, which was set up by Otto Frank in 1963.
The Anne Frank House said in a statement that it "finds it regrettable that the archives cannot remain in the Anne Frank House."
The museum said it did not dispute who owned the archives, but had not been able to return the documents immediately because they were on long-term loan.
"The Anne Frank House finds it deeply regrettable that the two organizations stood in opposition to each other in court," Anne Frank House director Ronald Leopold said.
"We hope that with this court ruling we can now put this period behind us, and that the partnership… can be resumed in close consultation and dialogue, in the interests of the legacy and the spirit of Anne Frank," Leopold said.
Anne Frank's diary is a moving account of her two years in hiding from the Nazis with her family in a secret annexe that is today a popular museum in central Amsterdam.
She died in 1945 aged 15 at the Bergen-Belsen concentration camp in Germany.
The case did not involve the actual Anne Frank diaries, which belong to the Dutch state and have been given to the Anne Frank House on permanent loan.
"We didn't expect anything else," Yves Kugelmann, a member of the board of the Anne Frank Fonds Basel, told AFP.
"The situation is clear, the ownership was clear, the international law is clear," he said.
"It was strange to have to go to court, it was so clear that it was a loan and nothing else."