It is always a mistake to start a war. You can usually get away with defending yourself, but even then it takes a heavy toll. Look at what happened to the world after WW II. Germany was a burned out ruin and Britain was in a state of collapse even though it "won". The economic health of the world was severely damaged and it took many years to rebuild.
A war between two nations is similar to a war between two individuals. Once hostilities start, even if one of the antagonists is apparently beaten, hostilities will continue. The "loser" will find ways to get back at the "winner", even if it is only by damaging him behind his back.
Right now we see this demonstrated in Iraq. The "simple" war envisage by those who began it has now become a complex mess with the "losers" taking more and more desperate and insane actions to damage the "winners".
A solution is now more difficult to come up with than before the whole thing started.
My solution, for what it is worth, is for the US to get out of there as quickly as possible. The presence of US soldiers, dressed in a very "alien" way is a constant antagonizer for the extremists who are already in a pretty crazed state.
The country should be handed over to Iraqis and they should start running their own country. The US should completely and without any doubt get out. They should not leave US companies behind to assist in rebuilding because these will simply become targets. Everything American, every reminder, every symbol must go. This probably won't stop all the terrorism, but it will cause it to decrease tremendously.
Next is for the Iraqi government to distribute the book "The Way To Happiness" in its appropriate translation. This book has been proven to bring calm to areas where it is distributed. Every school should teach it to the kids, the police should hand it out, it should be distributed with every newspaper and any other means of getting it out to the people should be carried out.
That would be a starting point to bring calm to Iraq.