The skeleton was found by council workmen at Victoria Primary School in the Newhaven area of Edinburgh, and later carbon dated by experts to the 16th or 17th century.
The school is near Newhaven Harbour, the closest port to Scotland's capital, which was once the site of a gibbet in which the bodies of executed criminals were displayed as a warning to others.
At first, archaeologists thought the man's skeleton was from the Bronze Age, due to the poor condition it was found in.
However, further investigation and carbon dating revealed the man had died much more recently. Due to the condition of the skeleton and its proximity to the harbour and gibbet rather than any of the three nearby graveyards, it is believed he was executed, either for piracy or another crime, and displayed in the gibbet before being buried in a shallow, unmarked grave.
The firm which uncovered the skeleton, AOC Archaeology, worked with forensic artist Hayley Fisher to create a reconstruction of the face of the man, who is believed to have been in his fifties when he died.
Laura Thompson, the headteacher of the primary school, said: "The pupils think it's fantastic that a skeleton was found deep underneath their playground."
"The archaeologists will hold a special lesson with some of the children about how they have used science to analyse the remains and it will be a good learning opportunity for them."
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies