Inhabited by Native Americans for thousands of years before European exploration, Nuevo México was colonized by the Spanish in 1598 as part of the Imperial Spanish viceroyalty of New Spain. Later, it was part of independent Mexico for a short period before becoming a U.S. territory and eventually a U.S. state as a result of the Mexican–American War. Among U.S. states, New Mexico has the highest percentage of Hispanics, including mostly descendants of the original Spanish colonists who have lived in the area for more than 400 years beginning in 1598. It has the second-highest percentage of Native Americans as a proportion of the population after Alaska, and the fourth-highest number of Native Americans after California, Oklahoma, and Arizona. The major Native American nations in the state are Navajo, Pueblo, and Apache peoples. The state's demography and culture are shaped by these strong Hispanic and Native American influences and expressed in the state flag. Its scarlet and gold colors come from the royal standards of Spain, along with the ancient sun symbol of the Zia, a Pueblo-related tribe.