In the heart of IS’s would-be caliphate, PM vows history won’t repeat