Jihadists rolled across vast swathes of Iraq and Syria almost unopposed until Kurdish fighters said no more.