A U.S. District Court ruled Monday that patents for one of Allergan PLC’s best-selling drugs are invalid, potentially opening the door for generic competition.

Shares of the pharmaceutical company fell 4.9% to $196.70 during afternoon trading following the decision to invalidate four patents for Allergan’s dry-eye drug Restasis. Allergan has said it plans to appeal the decision.

Allergan...