BAGHDAD—Prime Minister Nouri al-Maliki relinquished power on Thursday, ending eight years of tumultuous rule and opening a new political chapter that U.S. officials hope will move Iraq toward a more united front against marauding jihadists.

The surprise move deflates a potential crisis after Mr. Maliki had disputed in court the naming of another politician to the premiership and ominously deployed extra security forces across Baghdad.