It was one of the longest-enduring and most baffling mysteries to face Australian historians and scientists: what ever happened to the body of famed bush ranger and folk hero Ned Kelly?

But 130 years after Kelly was hanged for the murder of three policemen in Old Melbourne Gaol, the nation has finally got an answer.

Researchers from the Victorian Institute of Forensic Medicine have announced that, after an exhaustive 20-month search that included testing of more than 30 skeletons and a trip to Argentina, Kelly's remains have been positively identified.

The remarkable discovery was made by matching DNA from Kelly's sister's great grandson, Leigh Olver, with skeletal remains found in a mass grave in Pentridge Prison in Melbourne. The almost-complete skeleton, found in an unmarked wooden axe box, bore bullet wounds on the elbow, thigh and foot, sustained in the moments before Kelly was captured.

Robert Clark, the Victorian Attorney General, said the efforts of the forensic team to identify the remains of "one of the most controversial characters" in Australian history were extraordinary.

"To think a group of scientists could identify the body of a man who was executed more than 130 years ago, and moved and buried in a haphazard fashion among 33 other prisoners most of whom are not identified, is amazing," he said.

Kelly wrote his place in Australian history when he and a gang of three other men took up arms against the British constabulary, robbing banks and becoming a symbol of Irish-Australian defiance against the authorities.

After shooting dead three policemen in 1878, the gang remained on the run for two years, while Kelly's fame as a Robin Hood-style figure grew.

But his luck ran out in 1880, when – wearing a home-made suit of steel armour – he was finally arrested following a shoot-out with police.

He was hanged in Old Melbourne Gaol later that year, aged just 25, and his body dumped in a mass grave in the prison yard. In 1929, during building work at Melbourne Gaol, the graves were relocated to Pentridge Prison, further complicating efforts to find him.

There he may have remained forever, but in 2009, the hunt to track down Kelly's body was kick-started when a farmer handed a skull to police, claiming it belonged to Kelly.

In an attempt to find a match for the skull, researchers exhumed 34 bodies from Pentridge Prison.

The resulting CT scans, X-rays and pathology and odontology tests found that the skull did not belong to Kelly – and may in fact belong to notorious British killer and Jack the Ripper suspect Frederick Deeming – but that one set of bones did.

Dr Richard Bassed, part of the VIFM team that worked on the Kelly remains, said identifying the remains was only possible because when Kelly was killed prison wardens covered his body in lime, which, instead of accelerating decomposition, actually helped to preserve the bones.

But extracting DNA from the remains was difficult, and researchers had to call in the help of a lab in Argentina, which has experience in obtaining DNA from war crime victims. Eventually the hard work paid off.

"We spent a huge amount of effort over a long period of time, our biggest fear was that we wouldn't get any result at all," he said.

"Getting a result was great, the fact that we found an almost complete skeleton with injuries consistent to his bullet wounds was beyond what we had hoped for."

But the search is not over. The team still wants to find Kelly's skull, which Dr Bassed said it could be anywhere, but would be easily identifiable because it would be missing a piece at the back.

"When Melbourne Gaol was knocked down for development there were stories of passers-by coming in and picking up bones and skulls and running off with them," he said.

"So it could well be sitting in someone's grandfather's shed or in a dusty cupboard, and hopefully one day someone will notice it.

"Maybe this story will help bring his skull back to him, it would be great to have him all back together."

In the meantime, Kelly's family will be consulted on the appropriate resting place for his remains.