Afzali was an engineer and a captain in the Imperial Iranian Navy. After the 1979 revolution, he continued to serve in the Navy and took part in the homeland–Iraq War. Then Iranian president Abolhassan Bani Sadr appointed him as the commander of the Navy in June 1980.He was also special adviser of then speaker of the Iranian parliament, Ali Akbar Hashemi Rafsanjani.