California was originally a Spanish colony. When Mexico gained independence in 1821, it claimed California from Spain. Mexico neglected California. By 1845, California had become a semi-automonous region. Californios, of Spanish decent, began to formulate plans for the future. Concurrently, the USA and Mexico were close to war over Texas. American immigrants, threatened by deportation because of their illegal status in California, rebelled, with the support of the US Navy, and proclaimed The Bear Flag Republic. This republic was short lived and confined to an area near San Francisco. Twenty five days after its proclamation the republic was over when the 100-200 men of the "California Battalion" were merged with the American military and the American flag was raised above the Sonoma Barracks.

More Info: www.history.com