In 1748 Muhammad Shah was succeeded by his son Ahmad Shah, who shortly afterwards was appointed Safdar Jang. The Durrani invasions of Nadir Shah in 1739 and Ahmad Shah Durrani in 1748 had severely shaken the stability of the central government, and given to the provincial governors a dangerous degree of power. One of the most influential of these was Ali Muhammad in Rohilkhand, and the new "wajir", who had already quarrelled with him, looked with apprehension on his growing prestige. With Qaim Khan, the son of Muhammad Khan, he had also a hereditary feud, and he determined to set his two enemies at one another's throats, being certain to be himself the gainer whatever the event. Accordingly, on the death od Ali Muhammad in 1749, after an abortive attempt to overthrow his successor by other means, an imperial farman was issued to Qaim Khan conferring on him the mahals of Bareilly and Moradabad wrongfully usurped by Sadullah Khan, the son of Ali Muhammad.