The mystery man, who was not named by police for privacy reasons, has been identified as a 74-year-old German citizen with Iranian roots, police said.
Police had been investigating the man's identity since March, when he was found unconscious in a park, apparently having collapsed while jogging.
The man, who then fell into a coma, carried no ID on him, only two unmarked keys and €15 in cash.
No one reported him missing and no family members or friends responded when police released photos and appeals for information.
Police were stumped. The man had never been arrested, his fingerprints werent registered in police files, and neither was his DNA.
With nothing else to go on, investigators this week resorted to a more scattershot approach.
Ten teams of trainee police officers went around the neighbourhood where the man was found, trying copies of both keys in apartment door locks to see if they could find a match.
Police used to a map to search the neighbourhood. Photo: DPA
But after trying over a thousand doors with no luck, the operation was temporarily suspended. Then, on Thursday, police were finally given a lead.
A neighbour had seen a photo of the mans keys in the newspaper and thought they looked similar to his own.
“Last night a neighbour of the jogger called our missing persons post,” wrote Berlin police on Twitter. “He recognised the key. In the apartment the mans ID card was found. Thank you for your support in this unusual case.”
Uwe & Heiner von unserer #Vermisstenstelle sind erleichtert darüber, dass das monatelange Rätsel um den unbekannten Jogger endlich gelöst ist.
Mit der nötigen Gelassenheit und viel Optimismus gingen sie den zahlreichen Hinweisen nach.
— Polizei Berlin (@polizeiberlin) July 12, 2018
Officers tried the house door, found a match and were finally able to enter the mans apartment in Brandenburgische Straße in Berlins western Wilmersdorf district.
The missing persons department of the regional LKA criminal office has thanked all involved with identifying the man, including residents' tip offs.
The man, who is still in a coma, is being looked after in the intensive care unit of Berlins Charite hospital. A legal caretaker has been assigned to his case, and will continue to search for family members.
The man in a coma in the hospital when police were still trying to identify him. Photo: DPA
Such cases are extremely rare in Germany, but experts fear they may become more common in an increasingly isolated society.
A recent survey suggested two-thirds of Germans are worried about loneliness and there have been calls for intervention by the German government to tackle the problem.