He lost that post in August 1978 when he was arrested for an alleged plot against President Nur Mohammad Taraki, a member of the rival Khalq faction of the party. The PDPA Politburo ordered the arrest of Keshtmand and Public Works Minister Muhammad Rafi'i for their part in the possible anti-regime conspiracy. He and the other inmates went through severe torture and long imprisonment. He remained in prison and was sentenced to death, but this decision was revoked and he was resentenced to 15 years in prison.