Trained doctor served in administrative roles before rising to lead the Islamic Republic's military for 27 years