BAGHDAD — As the bloody battle to retake Mosul from the Islamic State ground on for months, with losses in lives and infrastructure piling up, soldiers and civilians kept in their minds an image of what victory would look like: capturing the historic, and symbolic, Al Nuri Grand Mosque and its distinctive leaning minaret.

It was there, in the summer of 2014, that the Islamic State leader, Abu Bakr al-Baghdadi, ascended a pulpit and declared a caliphate after his fighters took control of Mosul and swept through other parts of northern Iraq and Syria. It was the last time Mr. Baghdadi was seen in public.

On Wednesday night, with the terrorist group on the cusp of losing control of Mosul and with it its claim to a caliphate straddling the border of Iraq and Syria, Islamic State fighters packed the building with explosives and took it down.