Khalili was born in Wardak Province and attended a religious school. He participated actively in the Afghan resistance during Soviet Invasion. He also served as Minister of Finance of Afghanistan during the Mujahideen government in the early 1990s.