On 19 December 1918, as a captain, Aliyarbayov joined the national army formed by Musavat of the Azerbaijani Democratic Republic, serving as the captain of the 2nd Baku Infantry Regiment. Pushed back by the Red Army in Russia, the Russian Volunteer army led by Anton Denikin was scattered throughout the country. After capturing Derbent, the White Guardsmen, tried to invade Azerbaijan but were stopped by Aliyarbayov and his forces in Gusar. On 7 March 1919, by the decree of the Minister of War and the General of Artillery Samad bey Mehmandarov, Aliyarbayov was appointed as the acting assistant to the Baku District military commander. In this capacity, he led the military conscription of civilians in Baku and its surrounding districts into the Azerbaijani National Army. He continued to serve until the Red Army invasion of Azerbaijan in 1920.