This Republic ended suddenly , however , when Commodore John D. Sloat of the United States Navy sailed into San Francisco Bay . He said that California was now part of the United States . When Commodore John D. Sloat of the United States Navy sailed into Monterey Bay and began the military occupation of California by the United States .