Historian Lucy Worsley and the painting featuring Peter the Wild Boy on the staircase of Kensington Palace. Photograph: Eamonn McCabe for the Guardian

The condition that affected Peter the Wild Boy, a feral child found abandoned in a German forest and kept as a pet at the courts of George I and II, has been identified more than 200 years after his death.

Peter's charming smile, seen in his portrait painted in the 1720s by William Kent on the king's grand staircase at Kensington Palace, was the vital clue.

Lucy Worsley, the historian at Historic Royal Palaces who has been researching Peter's strange life, suspected from contemporary accounts that he was autistic.

She showed the portrait and gave the description of his physical characteristics and odd habits to Phil Beale, professor of genetics at the Institute of Child Health.

Beale ran the symptoms through his database of chromosomal disorders, and came up with a diagnosis of Pitt-Hopkins syndrome, which was identified in 1978, centuries after Peter's death.

Its most distinctive effect is clearly shown in Peter's portrait, his curvy Cupid's bow lips.

Other Pitt-Hopkins symptoms shared by Peter included short stature, coarse hair – the portrait shows him with a thick, curly mop – drooping eyelids and thick lips.

He was also said to have two fingers fused together, which may have been clubbed fingers, also sometimes a symptom.

His mental development would also have been affected. Together his symptoms explain to Worsley – who will discuss the discovery on the BBC Radio 4 Making History programme on Tuesday – how he ended up alone and naked in a forest.

"Certainly this was enough to explain why he was abandoned by his family, and once captured in the forest like a wild animal, why he was thrown into the local house of correction with the vagrants and thieves," said Worsley.

"He was actually quite lucky that King George I heard about him, and summoned him to court, even though there he was treated like a performing dog rather than a damaged little boy."

Worsley uncovered Peter's history while researching the courtiers and royal servants who appear in Kent's wall painting at Kensington Palace for her book Courtiers, published last year. The last piece of the puzzle has been solved now.

Worsley says she has been fascinated by Peter, who capered like Shakespeare's Puck in the solemn and etiquette stifled court. The servants had difficulty persuading him to walk instead of scuttling about on hands and knees, to sleep in a bed and to wear his green suit and red socks – he was terrified when he first saw a man taking off stockings, believing he was peeling off his skin.

George I gave Peter to his daughter-in-law Caroline, who was interested in science and philosophy, at a time when debate was raging about nature versus nurture, rational intelligence and the soul. He lived on at court when she became Queen.

Although he was treated kindly by his guardian, the Scottish doctor John Arbuthnot – by his side in the painting – he never learned to speak more than his name, and he wore a brass collar like a slave or a dog so he could be restored to his "owners" if he wandered off.

When he first came to England he was a media sensation in Georgian London, the subject of newspaper articles, poems and ballads – often satirising the extravagance and tortuous etiquette of the court. One mockingly described him as "The Most Wonderful Wonder that ever appeared to the Wonder of the British Nation".

When Jonathan Swift – suspected as co-author of the wonder pamphlet – was called to meet Caroline, he commented that since she was interested in a wild German boy, she also wanted to meet a wild Irish cleric.

Peter long outlived his royal patrons, and after Caroline's death in 1737 was sent to live on a farm in Hertfordshire owned by a retired courtier, where he lived into his 70s on a pension of £35 a year. He was buried in the churchyard of St Mary's at Northchurch near Berkhamsted, Hertfordshire. His simple gravestone reads: "Peter the Wild Boy 1785".

Worsley said: "He was a famous figure in Georgian times and he hasn't been forgotten today, people still lay flowers on his grave.

"It's hugely satisfying to winkle another secret out of the painting, which I've been obsessed with for some years now."