Monterey was the capital of Alta California under both Spain and Mexico. It was the only port of entry for taxable goods in California. In 1846 the U.S. flag was raised over the Customs House, and California became part of the United States after the ensuing Mexican-American War.