People here however often just call it "México", which can be quite problematic. There is the City of México, the State of México (which borders the city to the east, north and west) and the nation of México (which is officially called "Los Estados Unidos Mexicanos"... the United Mexican States). The name comes from the Aztecs, who actually called themselves the Mexica.
The even more commonly used name for the capital city is D.F. (which in Spanish is pronounced "day efay"). D.F. is the abbreviation for "Distrito Federal". Just as our capital Washington is located in the District of Columbia, the Mexican capital is within a Federal District which is not a part of any state.
The Federal District (Mexico City) is shown in blue.
The neighboring State of Mexico is shown in red.
The people of Mexico City are referred to as "chilangos"... which can be either a derogatory or an affectionate term. The Royal Spanish Academy in Madrid, the final arbiter of the Spanish language, recently proclaimed that a resident of Mexico City is a "mexiqueño", which will certainly be confused with "mexicano" (a citizen of the nation of Mexico) or a "mexiquense" (a resident of the State of Mexico). The word "defeño" (from D.F.) has emerged to refer to someone who lives in the Federal District (although that word has not been recognized by the Royal Academy).
Well, suddenly, with the stroke of a pen, "D.F." and "defeño" are obsolete. The Federal District has been abolished. Mexico City... "la Ciudad de México"... is now the 32nd state in the United Mexican States.
Have I thoroughly confused you???