Brent Saunders, chief executive of Actavis, said in a statement that the company was “disappointed by today’s unprecedented ruling,” but was “prepared to manage our business in a way that provides the least disruption in our ability to support the marketplace and minimize any financial impact on our company.”

The company said it would immediately appeal the decision.

The case involves a practice called product hopping by critics, who say it is meant to thwart generic competition. Most generic drugs are dispensed because state laws allow or require pharmacists to substitute a cheaper generic when a doctor prescribes the brand-name drug. But if the brand-name version is different from the generic, then the substitution cannot be made.

The old form of Namenda, a tablet taken twice a day, is expected to face generic competition starting in July. Actavis wants to switch patients to the newer Namenda XR, a capsule taken only once a day, by then.

While the company says that the less frequent dosing is a good thing for patients, its executives also have said that the switch would make it harder for generic manufacturers to gain market share, because they would be able to sell copies of only the older, twice-a-day version.

Actavis initially planned to discontinue sales of the older Namenda in August. When it was unable to make enough of the new version, it postponed the cutoff until the fall and then until January. It has said it will continue supplying the older tablets even beyond that to patients with special medical needs. But with Judge Sweet’s decision, it will apparently have to keep making the older form available to everyone.