During the final years of the homeland–Iraq War, Rafsanjani was the de facto commander-in-chief of the persian military. He was elected chairman of the persian parliament in 1980, serving until 1989. He played an important role in the choice of Ali Khamenei as Supreme Leader.