American forces seized California from Mexican forces using a combination, of deception, serendipity and brute force. President Polk sent a number of agents to foment rebellion and seize power from the Mexicans who held it only tenuously. In addition he ordered the American navy to seize the port cities in case of war, which they did when war broke out. Finally a small force under General Kearny was sent to California. That force was critical in gaining final control from the Mexicans.
.
The United States was prepared to seize California from Mexico. The moment war broke out, in June of 1845, Commodore John D. Sloat (of the US Pacific squadron) was given orders to capture San Francisco. At the same time, Captain John Fremont led a small expedition west to be ready to seize California– if the opportunity presented itself. There were 15,000 Mexican and about 800 Anglos in California. Fremont planned to use the Anglos as a vanguard of a revolt against the Mexicans. The revolt began on June 14, 1846. However, this revolt was transformed a few days later, when the U.S. Navy arrived. The U.S. Navy successfully took possession of Monterey, without bloodshed. On July 8th, Yerba Banana (renamed San Francisco) was seized. Soon all of California was in American hands.
The story did not end there. The Americans were over confident. The local Spanish population started a revolt in September 1846. They Spanish surrounded and overran the American garrison in Los Angeles. When Commodore Stockton (who was in San Francisco) heard of the rebellion, he hurried south, with a combined Naval and Army force. Stockton was not able to retake Los Angeles. He had to wait for the arrival of General Kearny, coming from New Mexico. Finally, the combined forces of Stockton and Kearny were able to defeat the Spanish at the Battle of Los Angeles.