During an ERCP, an endoscope is passed through the patient's mouth, down the esophagus through to the stomach and through the pylorus to the duodenum. In the second part of the duodenum, the ampulla of Vater is visualised and the endoscope passed into the ampulla into the pancreatic duct. A radio–opaque dye is then injected so that the biliary and pancreatic ducts can be seen on X–Ray.
ERCPs are used for both diagnostic and treatment purposes. Occasionally, stones can be removed during an ERCP procedure and a stent can be left in the common bile duct to allow drainage of bile when an extra-biliary mass (such as a cancer in the head of the pancreas) is compressing the bile duct shut.