The solution is very simple and very fair. Facilitate the formation of Iraqi government of national unity by including the representation of all faction in a balanced way (Sunni, Shiites, tribes, regions, Christians, Kurds and even moderate clean Baathists.) Make sure they can function on their own and establish constructive cooperation and get out. One can leave a few well trained troops to protect the stability of the new government. So long as the new government is a real (spontaneous and not pre-made), inclusive representation the population will see it as its own.
Inevitably when one leaves a few troops in bad guy country they end up dead. Since a few of those troops are known to me personally and each and every one is an American soldier, I would take umbrage at that.
There are no easy solutions, the right way can many times be the hard way. Waving the magic wand doesn't work.