The Somali government controls only small parts of Mogadishu after more than three years of fighting with Islamist militants .