He served as the 6th and last Prime Minister of the country from 15 March 1989 to 31 August 1991. Masheke became Prime Minister when the previous Prime Minister Kebby Musokotwane was removed and given an overseas diplomatic post as then-President Kenneth Kaunda believed that Musokotwane was aiming to replace him and take over Zambia as the next President. The role was abolished in 1991 when Zambia adopted a new Constitution owing to discussions between United National Independence Party (the only legal polictial party in Zambia at the time) and Movement for Multi-Party Democracy (an opposition party) to allow for multi-party elections to be held later the same year.
He held the position of 6th and final Prime Minister of the nation from 15 March 1989 to 31 August 1991. Masheke assumed the role when the preceding Prime Minister Kebby Musokotwane was replaced and assigned an overseas diplomatic assignment as then-President Kenneth Kaunda believed that Musokotwane aimed to supplant him and assume Zambia's presidency.