text: Today, China has between 26 and 28 Hainan gibbons left, but government records that date back to the 17th Century show that gibbons were once widespread across half of the country.
  The apes began to disappear from the documents about 150 years ago, corresponding with population growth.
  The study is published in the Proceedings of the Royal Society B.
  Hainan gibbons are now limited to a few isolated patches of forest in the south west of China.
  They live in just four social groups, one of which was only discovered a few weeks ago.
  Understanding this population crash has been difficult, but the old government documents have helped to reveal when and how the numbers fell.
  Dr Sam Turvey, from the Zoological Society of London, said: "China is one of the few places in the world that has a very very rich, long historical record.
  "Because it has had such a complex bureaucracy for so long, there has been a lot of need for reporting - not just numbers of households for tax purposes and things like that, but also in terms of the kinds of  natural resources that were available in the immediate environment."
  These included records of animals, including gibbons, he said.
  "We looked at the pattern of disappearance of gibbons through time and how that varied from place to place and the different environmental conditions and human pressures that were also present in these places."
  The archives show that gibbons were a common sight in about 20 provinces in China well into the 17th and 18th Century.
  However, Dr Turvey said it was "a stark contrast to their very imperilled position today".
  "We see a really steep increase in population decline and real population collapse across China about 100-150 years ago," he added.
  "And this correlates with demographic expansion in China towards the end of the Imperial era and through the 20th Century, and the massive increase in deforestation and human population growth through the time of the Chinese Republic and the establishment of the communist party."
  The researchers said a better understanding of the animals' decline would help them to establish a conservation plan for the country's last few Hainan gibbons.
  Dr Turvey said: "It is an incredible privilege to be able to see gibbons in China in the wild.
  "The Hainan gibbon is such as rare species, but knowing that this species is still hanging on there gives you hope that conservation will be able to bring that population back from the brink."
  Follow Rebecca on Twitter
target: Historical Chinese documents have helped scientists to track the decline of the world's rarest primates.