It is a victory for Iraq to have cleared nearly all of the city, which had a population of at least a million.