BAGHDAD - Iraqi lawmakers, under U.S. pressure, reached a last-minute deal yesterday on reapportioning parliamentary seats among various religious sects and ethnic groups that clears the way for national elections early next year.

The elections are seen as crucial to keeping a planned U.S. troop withdrawal on schedule.

Minutes before midnight, the deadline set by Vice President Tariq al-Hashemi to veto the electoral law if it didn't improve representation for his fellow Sunni Muslims, lawmakers hurried into parliament and voted on the deal. Hashemi later said he was pleased by the outcome.

"The crisis is over," Omar al-Mashadani, a spokesman for Speaker Ayad al-Samarraie, said late yesterday.

The revised elections law enlarges the body from 275 to 325 seats and redistributes them among the country's 18 provinces to satisfy the sparring groups.

No final date for the elections was set, but the United Nations has proposed holding them by Feb. 27. The elections were supposed to take place Jan. 16, a date made moot by weeks of political fighting that increasingly took on sectarian overtones.

The elections, and Iraq's political stability, are critical to President Obama's hopes of withdrawing all U.S. combat troops by August 2010, leaving about 50,000 U.S. military personnel for noncombat purposes.

The vote will also be a critical test for the Shiite-led government of Prime Minister Nouri al-Maliki, which has staked its future on a broad pro-Western political coalition with Sunnis and other factions.

His main challenge comes from within the Shiite ranks: an alliance of religious-oriented Shiite parties that include the biggest Shiite political group and anti-U.S. cleric Muqtada al-Sadr.

The final deal, voted on about 11:45 p.m. Baghdad time, was reached only after repeated intervention by U.S. diplomats and U.N. advisers, according to Iraqi lawmakers and other officials.

They said Obama administration officials pushed hard on leaders of Iraq's ethnic Kurds to accept fewer seats than the 48 they demanded for their semiautonomous northern region. The Kurds' eventual, if reluctant, agreement sealed the deal.

Salih Mutlak, a Sunni Arab lawmaker, said: "If it wasn't for the American intervention in the first degree . . . the law today would not have passed. This is the first time that the Americans used wisdom and logic and pressured the Kurds."

A Kurdish lawmaker said, however, that his group was swayed by U.S. guarantees.

"The Americans didn't place pressures, but they gave us important guarantees, and tomorrow the White House will probably issue a statement about it," Feriad Rawanduzi said.

The guarantees, he said, include a census next year in Iraq - the country hasn't had one since 1987 - and U.N. help in settling Arab-Kurd disputes over a broad swath of territory, including the oil-rich Kirkuk region.

"We must say that the result was acceptable to a certain limit; there was no other alternative," Rawanduzi said.

Hashemi, one of two vice presidents, said in an Iraqi television interview that the tough negotiations had "made our democratic process stronger." He added that "this outcome will change Iraq from a sectarian state to a civilized state."

Parliament passed the original elections law Nov. 8, but Hashemi vetoed it.

Hashemi complained that it didn't give enough representation to two million Iraqis who have fled the country, most of whom are believed to be Sunni Muslims, a minority that lost influence to the majority Shiites after the fall of Saddam Hussein.

The law was then amended, but it created additional seats for Kurds and left Sunnis feeling even more disenfranchised.

Last night's session took place under the threat of another veto by Hashemi if his demands were not met, and the specter of a political vacuum and reignited sectarian violence.

In the end, all sides appeared to have won something from the deal. Sunnis got greater representation, Kurdish areas increased their seats in parliament from 35 to 43, and Shiite Muslims also got more clout.

Though agreements have been reached before only to fall apart, there were high hopes that this one would stick.

Hashemi withdrew his veto threat early this morning.

"It is a decisive moment for Iraq's democracy and we congratulate the Iraqi people and their elected representatives," White House spokesman Robert Gibbs said in a statement.

This article includes information from the Washington Post, Associated Press, and Bloomberg News.