Miranda, therefore, became the capital of the Trás-os-Montes, seat of the bishopric (that included the residence of the bishop, canons and ecclesiastical authorities), military governorship and civil centre. In 1762, during the Seven Years' War, the army of Charles III of Spain invaded the Trás-os-Montes. During the course of his invasion, the gunpowder magazine (with over 500 barrels of powder) was hit by a cannon, destroying the four towers of the castle and many of the barrios in the vicinity. Approximately a third of the city's population (about 400 residents) were killed, resulting in the ruin of the religious, demographic and urbanized portion of Miranda. It was almost two years later (1764) that friar Aleixo Miranda Henriques (then the twenty-third bishop) would abandon Miranda, moving to Bragança, which had become a rival episcopal seat in the northeast part of Portugal. By 1680, it was the only ecclesiastical seat in the region. The area was served by a narrow gauge railway, the Sabor line "(Linha do Sabor)", which ran over 100 km between Duas Igrejas-Miranda and the southern terminus at Pocinho, where connections could be made to the main line to Oporto. The Sabor line closed in 1988. Miranda do Douro is located in a region that skirts the border between the Portuguese Trás-os-Montes region, and the Spanish autonomous community of Castile and León. The relief in this region is influenced by hard quartzite deposits near the border region, making erosion difficult, resulting in high escarpments and cliffs. The soils are composed of schists and granite bedrocks. The "Parque Natural do Douro Internacional" (), which encompasses the municipalities of Figueira de Castelo Rodrigo, Freixo de Espada à Cinta, Miranda do Douro and Mogadouro, includes an area of , along the border portion of the Douro River. It was created on 11 May 1998 to encompass the constituent territories that encompass the Rivers Douro and Águeda, along the Spain-Portugal border that include similar geological and climatic conditions, and to help support flora and fauna in the region, while allowing appropriate human activities. The creation of the complementary "Parque Natural de Arribes" in Spain, allowed the systematic protection of an area that encompassed the larger ecosystem and biome.