The digestive system develops between weeks 4-8 of gestation from the endoderm and surrounding mesoderm. The primitive gut forms and divides into the foregut, midgut, and hindgut. The foregut develops into parts of the pharynx, esophagus, stomach, duodenum, pancreas, and liver. The midgut rotates and returns to the abdomen, forming parts of the small and large intestine. The hindgut develops into parts of the large intestine and rectum. Errors during development can result in congenital abnormalities such as esophageal atresia, intestinal malrotations, and annular pancreas.