Germany's highest court has ruled that the parents of a dead daughter have the rights to her Facebook account under inheritance law.

The Federal Court of Justice (BGH) said online data should be treated the same as private diaries or letters, and pass to heirs.

The case involves parents of a 15-year-old girl killed by a train in 2012.

They sought access to her Facebook account to try to determine whether the death was suicide.

Aside from emotional closure, the parents also wanted to know whether the train driver was entitled to compensation - as would be the case in the event of a suicide.

Facebook had refused access to the account after their daughter's death, citing privacy concerns about the girl's contacts.

Under its current policy, the company only allows relatives of the dead partial access to the account, allowing them to change the page into an online memorial or to delete it entirely.

A lower German court backed the parents in 2015, supporting the claim that Facebook data was covered by inheritance law as the equivalent of private correspondence.

But in 2017, an appeals court backed Facebook and overturned the ruling, on the grounds that any contract between the girl and the company ended with her death and could not pass on to the parents.

The case went to the BGH, and her parents have now reportedly taken over the account.

Judge Ulrich Hermann said it was common to hand over private diaries and correspondence to legal heirs after death, and there was no reason to treat digital data any differently.

Moreover, the court added that the parents had a right to know who their child, a minor, had spoken to online.

In recent years, Facebook has come under increasing scrutiny in Germany - in particular over fake news on the platform.

The company introduced new tools in Germany to combat fabricated stories, shortly before the government approved plans to levy heavy fines on social media firms if they failed to remove inappropriate comments and content quickly.