In 1821, Mexico won the war against Spain for its independence, and part of the reward was the entire state of California. By 1827, Los Angeles became a popular rival of Monterey to become the capital of Baja and Alta California.