WASHINGTON—President Barack Obama said Friday he was bringing all U.S. forces home from Iraq by the new year, ending a war that stretched nearly nine years, divided the country, transformed the military and left an enduring mark on American history.

The chief effect of Mr. Obama's announcement was to end any chance of a substantial U.S. troop presence in Iraq after the end of the year, a disappointment for U.S. defense officials. It was an acknowledgment that Iraqis had refused to agree to a key U.S. condition for leaving...