The U.S. Food and Drug Administration and Barr were sued by the Association of American Physicians and Surgeons and other groups that sought to overturn the FDA's decision.
The U.S. District Court for the District of Columbia granted FDA's and Barr's motion to dismiss the suit.
The court said it agreed with defendants that plaintiffs failed had "to identify a single individual who has been harmed by Plan B's OTC (over-the-counter) availability," according to the ruling.
Plan B was approved in 1999 and the FDA broadened the approval in 2006 to allow sale to adults without a prescription. The pills must be kept behind pharmacy counters and only sold to girls younger than 18 years old with a doctor's order.
Separately, on Monday, another U.S. court found the patent for Bayer AG's Yasmin contraceptive drug to be invalid, paving the way for Barr to sell a generic version.
"It's a big win for Barr," Natixis Bleichroeder analyst Corey Davis said of the Bayer ruling. "This could be one of those nice generic products with a long tail on it," he said.