In 1808 he was selected by Lord Minto for the responsible post of envoy to the court of Ranjit Singh at Lahore; here, on 25 April 1809, he concluded the important treaty securing the independence of the Sikh states between the Sutlej and the Jumna.