Taipei (/ˌtaɪˈpeɪ/), officially known as Taipei City, is the capital and a special municipality of Taiwan (officially known as the Republic of China, "ROC"). Sitting at the northern tip of the island, Taipei City is an enclave of the municipality of New Taipei City. It is about 25 km (16 mi) southwest of the northern port city Keelung. Most of the city is located on the Taipei Basin, an ancient lakebed bounded by the two relatively narrow valleys of the Keelung and Xindian rivers, which join to form the Tamsui River along the city's western border. Formerly known as Taipeh-fu during the Qing era and Taihoku under Japanese rule, Taipei became the capital of Taiwan Province as part of the Republic of China in 1945 and has been the capital[a] of the ROC since 1949, when the Kuomintang lost the mainland to the Communists in the Chinese Civil War.