Alta California was formed in 1804 from the northern half of the Spanish colony of California, later becoming a Mexican territory after independence from Spain. During the Mexican-American War, Alta California was successfully invaded and annexed by the United States, becoming the American state of California in 1850.