A gastroretentive drug formulation for the sustained release of an active agent in the gastrointestinal tract comprises an internal layer or compartment comprising an active agent and one or more pharmaceutical excipients, of which at least one is a polymer and two membranes forming together an envelope around the inner membrane, each membrane comprising at least one polymeric combination of an enteric polymer which is not soluble in gastric juice, and an hydrophilic swelling polymer, and at least one plasticizer.