In a vote seen partly as a referendum on President George W. Bush and the Iraq war, Democrats have emerged with a solid majority in the U.S. House of Representatives and a narrow lead inthe final undecided race they must win to control the Senate.

Acliffhanger victory in Montana — after a slow count that stretched through Wednesday morning — guaranteed the Democrats 50 of the 100 Senate seats.

A win in Virginia, where Democrat Jim Webb led by about 7,000 votes with nearly all votes counted, would put them in command of both chambers for the first time in a dozen years.

Webb claimed victory on Wednesday but incumbent George Allen refused to concede defeat. A recount is considered likely. If the Republicans win in Virginia, they will retain control of the Senate through Vice-President Dick Cheney's tiebreaking vote.

Either way, Bush faces a painful two years as a lame-duck leader without a legislative branch he can depend on to enact laws and allocatemoney he wants in order to pursue his policies on Iraq and terrorism.

In the House (and possibly the Senate), Democrats will control committees with power to launch investigations and subpoena witnesses. There is little doubt they will pursue evidence of what they see as cronyism, corruption and incompetence in the Iraq war and reconstruction effort, and the Bush administration itself.

Responding to the setbacks, Bush faced reporters on Wednesday to announce the resignation of his defence secretary, Donald Rumsfeld, whose strategy in Iraq has left U.S. troops pinned down in aland descending into chaos.

Tuesday's mid-term elections, in which some Republicans sought to distance themselves fromtheir president'spolicies,shattered the Republican grip on the House.

By Wednesday afternoon, Democrats hadcaptured 228 House seats and led in four, putting them on track for a 30-seat gain if trends held in remaining unsettled races, the Associated Press reported. Party standings in that event would be 232-203.

The Democrats gained at leastfive seats in the Senate, where staggered elections meant that only 33 of the 100 seats were up for grabs.All 435 House seats were at stake in the elections, along with countless jobs, ranging from state governor to county drains commissioner.

With the Democrats in charge of the House, Nancy Pelosi is set to become the first female House Speaker, taking over from Republican Dennis Hastert.

"From sea to shining sea, the American people voted for change," Pelosi said from the party's election headquarters in Washington as the trend became clear. "They voted for Democrats to take our country in a new direction. And that's exactly what we intend to do."

Democrats knocked Republicans from Senate seats in Pennsylvania, Ohio, Rhode Island, Missouri and Montana. Republicans lost ground in every region of the country.

White House spokesman Tony Snow conceded the winds of change.

"The president has got a very active agenda for the next two years and you're going to need both parties," he said before Bush's address to discuss the mid-term results. "The president's not the kind of guy who is going to be sombre about things. They have not gone the way he would have liked."

Pundits said although the war in Iraq was not on the ballot, the Democrats had been able to make sweeping gains in the election because of public discontent with the war andthe Bush administration.

Tight races

In Montana,Republican incumbent Conrad Burnslost toDemocrat Jon Tester in a tight battle. With nearly all votes counted, about3,000 separated them, too many to give Burns the right to a recount.Problems with a voting machineinone countydelayed the count.

In the bitterly contested Virginia race, Webb's leadwas within the limits of a state lawgiving candidates whofinish withinhalf a percentage point of the winner the right to a recount.That meansthe official results might not be known until December.

InMissouri, where Claire McCaskill narrowly beat incumbent Senator Jim Talent, the race featured apolarizing ad on behalf of McCaskill,featuring Canadian-born actor Michael J. Fox supporting the candidate's position on stem cell research.

Meanwhile, Joe Lieberman's defeat in the Democratic primary to Ned Lamont earlier in the year was avenged. Lieberman, running as an Independent, won re-election to the Senate.

While many in the party criticized the one-time vice-presidential nominee for running despite the primary defeat, Lieberman has essentially vowed to be a Democrat in all but name.

Bob Casey, the son of a former two-term governor, became the first Democrat from Pennsylvania to be elected to a full term in the Senate since 1962.

Casey unseated Rick Santorum, an opponent of gay marriage who had stood behind Bush on the war in Iraq.

Republican Bob Corker won a hard-fought victory in Tennessee over Harold Ford Jr. The race had featured apolarizing Corker campaign ad that raised the ire of Canadian politicians and African-Americans,onethat even Corker described as "tacky."

Veteran senators cruise

Three veteran senators representing both sides of the aisle cruised to victory early in the evening.

Robert Byrd, who will turn 89 on Nov. 20, won in West Virginia. The Democrat earlier this year passed Strom Thurmond as the longest-serving senator in history, at 47 years and counting.

The second most senior senator, Edward Kennedy, who won in Massachusetts, was first elected for the Democrats in 1962.

Republican Richard Lugar, meanwhile, ran virtually uncontested in Indiana, on the 30th anniversary of first being elected to the Senate.

Republican veterans Trent Lott and Orrin Hatch were also re-elected. Hatch won his sixth term out of Utah, Lott his fourth from Mississippi.

Several new governors elected

Elections for governor wereheld in 36 states.All butone of nine incumbents not seeking re-election were Republicans. Included in that list were George Pataki (New York), Mitt Romney (Massachusetts) and Jeb Bush (Florida), all of whom are considered potential candidates to make a run for president.

Romney's successor made history. Democrat Deval Patrickbecame the first African-American governor in Massachusetts.

webb-jim-cp-11065544

Senate candidate Jim Webb gestures during remarks at an election night event on Tuesday in Vienna, Va. ((Evan Vucci/Associated Press))

As expected, Democrat Eliot Spitzer will replace Pataki. The New York state attorney has spent the last several years targeting payola in themusic industry and pushing for reforms on Wall Street.

The Republicans heldFlorida, where Charlie Crist will succeed Jeb Bush.

In Pennsylvania, Hall of Fame football player Lynn Swann failed in his bid to unseat Democrat incumbent Ed Rendell.

Republican Rick Perry won a second term in Texas, while Democrat Bill Richardson did the same in New Mexico.

In California, Arnold Schwarzenegger turned back the challenge of Democrat Phil Angelides.

"I love doing sequels," Schwarzenegger said during his victory speech.

Heading into the night, Republicans held 28 of the 50 governorships. The Democrats emerged from the elections with 28.

Voting delays

In addition to the Iraq war, exit polls indicated that the big issues on voters' minds were corruption, terrorism and the economy.

The process wasn't always smooth, with precincts in several states staying open later than scheduled because of problems with voting machines.

Most seriously, the FBI was investigating allegations that voters in Virginia had received phone calls intended to discourage them from voting or directing them to the wrong polling location.

With files from the Associated Press