ERBIL, Iraq — For decades, the pesh merga have enjoyed a fearsome reputation as unconquered mountain warriors, a storied band of guerrilla fighters who became the official guardians of the Kurdish enclave in northern Iraq. But when fighters from the Islamic State in Iraq and Syria rolled into Kurdistan in August, the pesh merga fled the front line, just a half-hour’s drive from the territorial capital, Erbil.

Their collapse left tens of thousands of defenseless residents in ISIS’ path. And it shattered widespread hopes that the Kurdish forces might succeed in checking the militants’ advance where the Iraqi Army had failed, further calling into question fundamental assumptions about Iraq’s security.

Though the Kurdish forces have reclaimed much of the lost ground in the past two weeks, rallied by a campaign of American airstrikes, the initial losses prompted hard questions about how the pesh merga could have failed their greatest test in more than 20 years.

It has also set Kurdish officials scrambling to try to overcome years of internal political and military divisions to answer the threat and to secure more military assistance from the United States and Iran.