Located on the Gulf of Mexico, Campeche was the principal seaport on the Yucatan Peninsula from the 16th to the 18th centuries. It subsequently endured attacks from European pirates who destroyed the city several times. To fend off these attacks, residents built a thick stone wall around the city, with only four gates to permit access.