Born in Edinburgh, Allan was apprenticed to a coach painter before studying at the Trustees' Academy in the city from 1799; David Wilkie was a fellow student and became a lifelong friend. Allan went to London in 1803 to continue his studies, possibly at the Royal Academy. In 1805 he went to Russia, where he was based until 1814, travelling widely in the region. On his return, he settled in Edinburgh where he painted scenes inspired by his travels as well as subjects from Scottish history and Sir Walter Scott's novels. He was appointed Master of the Trustees' Academy in 1826, elected President of the Royal Scottish Academy in 1838 and became the Queen's Limner for Scotland in 1841, the year he was knighted.