The ISI's role is complex. It has backed tribal militias to take on foreign militants in the tribal areas; and at other times it appears to be fighting an internal war as several deadly attacks by Islamic militants with links to the agency have been launched against ISI officers.