The tremor's epicenter was one mile north of Piedmont, about 13 miles east of San Francisco on the Hayward Fault.
"#earthquake tremors felt in #SanFrancisco. Always be prepared!" the city of San Francisco said on its official Twitter page.
The quake hit at 6:49 am (1349 GMT), at a depth of 3.3 miles, USGS said.
An AFP correspondent in Alameda, across the bay from San Francisco and near the epicenter, said he was awakened by a gentle rumble that ended with a sharp jolt after about five seconds.
More From This Section
Another California resident living near the epicenter also felt the ground shake.
"The center was just down the street. There was no damage, it just woke us up," photographer Frederick Neema told AFP.
An AFP reporter living in San Francisco itself said she felt the quake distinctly but there was no damage in her home.
The Hayward Fault runs from San Pablo Bay in the north to Fremont in the south, passing through the cities of Berkeley, Oakland, Hayward and Fremont, according to the USGS.