The answer to the OP’s question is, “It depends.” First, obviously on whether success in Iraq actually occurs. Second, assuming success does occur, it depends on when the success occurs. Only if success in Iraq is superbly timed would the Democrats be badly hurt.
For purposes of American politics, “success in Iraq” requires two accomplishments. 1) The withdrawal of the bulk of American troops, followed by 2) the survival of the elected Iraqi government, or at least some Iraqi government not dominated by the insurgents (a military coup installing a junta or Musharraf-type dictator would meet with indifference from most of the American electorate, for example). Accomplisment 1 is easy, of course. It’s accomplishment 2 that’s tricky. If the U.S. administration believed the elected Iraqi government had as much as a 75% chance of surviving without U.S. military support, the main body of troops would already be coming home.
The worst-case “success in Iraq” scenario for the Democrats would be if Bush withdraws 100,000+ soldiers over the August to October period, 2008, and (1) the Iraqi government does not immediately collapse into a pile of rubble, and (2) any insurgent offensive that ensues in the wake of the withdrawal is weak enough that it does not cause the public to anticipate the imminent downfall of the Iraqi government. In that scenario, just about any Republican candidate would be very likely to win the White House, and the Republicans would have a decent chance to take both houses of Congress back.
Even in the worst case scenario, the Democrats would not sustain much long-term damage. Contrary to the OP’s supposition, the Democrats are not significantly “invested in defeat,” because they are hardly invested in foreign policy at all; the party’s chief investment is in popular domestic issues. After the euphoria of victory wore off, the Republican party would still be deeply divided over fiscal responsibility and immigration. Terrorist attacks against U.S. allies and citizens abroad would continue. The Democrats would come back strong in 2010.
Any other timing of a success in Iraq would hardly hurt the Democratic party, and might even help it. Suppose, for instance, that the picture in Iraq were as rosy as the OP paints it. Contrary to appearances, suppose that the insurgency is now impotent, stability is returning, and thus the bulk of OIF forces withdraw in March and April. The clear beneficiary is Hillary Clinton, who voted for war and has consistently maintained that troops must remain in Iraq until “mission accomplished” can be declared. Barack Obama, who voted against the war and favored prompt withdrawal, loses his already slender chances. By November, the rush of euphoria has subsided and the main issues in the electorate’s mind are gas prices, health care, and immigration (remember that the Conservatives got voted out on bread-and-butter issues only months after Churchill won World War II, and Bush’s war record does not compare favorably to Churchill’s). Clinton’s nomination does have the effect of uniting the GOP, as the various factions will paper over all their differences in order to defeat the Queen of the Damned. Clinton might win, she might lose, but the Iraq war would play little part other than to secure her nomination.
But by far the least unlikely “success in Iraq” scenario would occur two to ten years down the road, because an independently viable Iraqi security force and a stable Iraqi government are almost certainly not going to emerge before that time. And success during that time frame is more likely to help the Democrats than the Republicans, because, absent an early success in Iraq, there is an excellent chance that a Democrat will be president for the next eight years. Rightly or wrongly, the Democrats would then be credited for turning a failed foreign policy around.
Of course, “success in Iraq” in any time frame is still unlikely. The surge has indeed temporarily reduced violence, but the insurgency remains active and reconciliation in the Iraqi government is as distant as ever. It was known from the start that the surge could not be sustained without a massive increase in Army personnel strength (read: conscription), and now force levels are inevitably being reduced. The return to pre-surge troop strength will probably result in a return to pre-surge violence.
The main point of the success-in-Iraq blather is to prepare the Republican party-in-the-electorate for next October’s story: that we were just on the verge of success in Iraq before those terrorist-loving scum, the Democrats, stabbed us in the back by ending the surge, just when it was working so well. That also is the point of the fatuous calls to “make the surge permanent,” so the Democrats can be blamed for failing to do so.