BAGHDAD—Iraqi and U.S. officials said Islamic State is on the cusp of defeat in Mosul and close to being driven out of Iraq, after the country’s military seized a mosque in the city where the extremist group’s leader first proclaimed a caliphate.

“We are seeing the end of the fake Daesh state,” Iraqi Prime Minister Haider al-Abadi said on Twitter, using another name for Islamic State. “The liberation of Mosul proves that. We will not relent,” he added.

Thursday’s...