Judge Motz ruled that a 1974 federal law overruled the Maryland state law, which had been backed by labor groups.

He said it was unfair because it forced the company to handle benefits in Maryland differently than it does in other states.

The Retail Industry Leaders Association, a trade association whose members include Wal-Mart and which had challenged the law, praised the ruling.

"The decision sends a clear signal that employer health plans are governed by federal law, not a patchwork of state and local laws. It also is a clear message that similar bills under consideration in other states and municipalities violate federal law as well," Sandy Kennedy, president of the Retail Industry Leaders Association, told Reuters.

Some critics of Wal-Mart who supported the state law expressed disappointment. "This decision does not change the fact that Wal-Mart doesn't provide company health care to over half of its workers," Paul Blank, campaign director for the activist group Wake-Up Wal-Mart, told Reuters.

"The District Court's decision, unfortunately, ignores legal and public support for requiring large, profitable corporations to pay their fair share for health care," the newswire quoted Blank as saying.

The law was the first of its kind in the country. Legislators in at least 13 other states proposed similar "Pay or Play" bills in the past year, according to the National Conference of State Legislators.