After an agreement brokered by the United States, the Soviets agreed to leave Iran, and sovereignty was restored to the Shah in 1947. The Shah ordered an invasion of the Republic of Mahabad shortly afterwards, the leaders of the republic including Qazi Muhammad were arrested and executed. Qazi Muhammad was hanged on 31 March 1947. At the behest of Archibald Roosevelt Jr., who argued that Qazi had been forced to work with the Soviets out of expediency, U.S. ambassador to Iran George V. Allen urged the Shah not to execute Qazi or his brother, only to be reassured: "Are you afraid I'm going to have them shot? If so, you can rest your mind. I am not." Roosevelt later recounted that the order to have the Qazis killed was likely issued "as soon as our ambassador had closed the door behind him," adding with regard to the Shah: "I never was one of his admirers."