Panama, officially the Republic of Panama, is a country located at the southern end of Central America, bordering South America. It is bordered by Costa Rica to the west, Colombia to the southeast, the Caribbean Sea to the north, and the Pacific Ocean to the south. Its capital and largest city is Panama City, whose metropolitan area is home to nearly half of the country's over 4 million inhabitants.
Before the arrival of Spanish colonists in the 16th century, Panama was inhabited by a number of different indigenous tribes. It broke away from Spain in 1821 and joined the Republic of Gran Colombia, a union of Nueva Granada, Ecuador, and Venezuela. After Gran Colombia dissolved in 1831, Panama and Nueva Granada eventually became the Republic of Colombia. With the backing of the United States, Panama seceded from Colombia in 1903, allowing the construction of the Panama Canal to be completed by the United States Army Corps of Engineers between 1904 and 1914. The 1977 Torrijos–Carter Treaties agreed to transfer the canal from the United States to Panama on December 31, 1999. The surrounding territory was returned first, in 1979.