The quake took place at about 6:34 a.m. local time with an epicenter about 23 miles east northeast of West Yellowstone, Mont., and a depth of 4.2 miles.
Peter Cervelli, a spokesman for the U.S. Geological Survey's Yellowstone Volcano Observatory, said the earthquake's epicenter was near the Norris Geyser Basin. He said any damage from the tremblor would likely be minor, and there were few visitors at the park at the time.
Smaller quakes were recorded in the region later in the morning in the 3-magnitude range.
The earthquake was the largest at the national park since Feb. 22, 1980.