An ectopic pregnancy occurs when a fertilized egg implants and grows outside the main cavity of the uterus, most commonly in the fallopian tubes. This type of pregnancy is non-viable and can lead to serious health complications if not treated promptly.