In a stinging defeat for Gov. Robert L. Ehrlich Jr. and a major victory for organized labor, the Maryland General Assembly decided on Thursday overrode the veto of a closely-watched bill that will force Wal-Mart to pay more in health benefits to its employees.

The legislation apparently makes Maryland the first state in the nation to enact such a requirement, and was heavily lobbied by both business and labor. The bill was passed in last year's session of the Legislature and vetoed by Ehrlich, a Republican, in May. Since then, passage of the bill over the governor's veto has been a major priority of the Assembly's Democratic leaders and their labor allies.

The bill does not specifically target Wal-Mart. Known as the Fair Share Health Care Plan, it requires companies employing more than 10,000 people to spend at least eight percent of their payroll on health care benefits. Wal-Mart is the only company of that size in the state that does not already do so, though the giant retailer does offer health insurance to its employees.

Thursday's votes, first in the Senate and then in the House of Delegates, were close. A three-fifths majority in each house was needed to override the veto, and the vote was largely along partisan lines as the governor had fought hard to defend his veto.

In a statement issued after the House vote, a spokesman for Ehrlich said that the governor had been "cautiously optimistic" that the veto override would fail, "but unfortunately, that was not the case."

"This is a loss for the small businesses who will be targeted next, and it sends a terrible message to employers who are considering bringing good, high-paying jobs to Maryland," said Henry P. Fawell, the governor's spokesman.

In appealing to members of the House to vote for the legislation, Del. Kumar P. Barve, D-Montgomery, the majority leader, warned that Maryland should be the first state to stand up against what he called "the race to the bottom" of companies cutting employee benefits to save money.

"If we take no action tonight the competitors of Wal-Mart will only have one economic response — they too will begin to shed employee benefits," Barve said. "They will have no other choice."

Supporters of the bill accused Wal-Mart, the world's largest retailer, of shorting their employees on health care and forcing them into the state's Medicaid system.

"It says to these conglomerates in Maryland, don't dump your uninsured employees into our Medicaid system," said Sen. Gloria G. Lawlah, D-Prince George's, the bill's sponsor.

In a statement issued after the vote, Wal-Mart noted that there are 786,000 Marylanders without health insurance and that less than one half of one percent of them work for Wal-Mart.

"This vote was never about health care," the company said. "This was about partisan politics in the Maryland gubernatorial race. In allowing a bad bill to become a bad law, the General Assembly took a giant step backward and placed the special interests of Washington, D.C. union leaders ahead of the well being of the people they serve."

But a jubilant Fred D. Mason, Jr. president of the Maryland State and D.C. AFL-CIO, called the vote a "great day for the state of Maryland" and expressed the hope that the Assembly's vote would indeed be a precedent for the rest of the country.

That was one of the few points on which both sides of the heavily lobbied bill agreed.

"You will see what was seen as a small leak in Maryland will become a raging torrent," said Sen. Paul G. Pinsky, D-Prince Georges, a supporter of the bill.

Capital News Service contributed to this report.