Ranjit Singh was appointed Lahore governor by the Afghan ruler in 1799.