The capital of Spain is Madrid. It is the most populous city in Spain with almost 3.5 million inhabitants and serves as the political, economic, and cultural center of the country. Madrid is located in the central part of the Iberian Peninsula and has been the capital since the 16th century when it was officially made the capital by King Philip III. The city houses the official residences of both the King of Spain and the Prime Minister, as well as the main government institutions. Madrid is also the capital of the surrounding autonomous community known as the Community of Madrid. The city's selection as the capital was influenced by its central location, defensible position, and the preference of King Philip II for a city without established noble power centers that could overshadow the monarchy. Madrid also benefits from a favorable climate and natural surroundings, such as proximity to mountains and water sources. In summary, Madrid is the capital of Spain, serving as the seat of government and monarchy as well as the cultural and economic hub of the country.