In 1821, Mexico won its independence from Spain, cementing the decline of the mission era. In 1835 an American, William Richardson, became the first permanent resident of Yerba Buena. By the 1840s dozens more Americans came to Alta California and began agitating for independence. After a briefly declared “California Republic,” they welcomed the arrival of James B. Montgomery, a U.S. Navy captain who came ashore on July 9, 1846, to raise the U.S. flag in Yerba Buena’s plaza (today’s Portsmouth Square).