ATHENS — A strong earthquake shook Athens on Friday afternoon, prompting panicked residents to flee office buildings and homes and pour into the streets of the city, though there were no immediate reports of any injuries or damage.

The quake, which happened shortly after 2 p.m., had a magnitude of 5.1, according to the Euro-Mediterranean Seismological Center, and the epicenter was in Parnitha, about 15 miles from the Greek capital.

Many in Athens felt the tremors, and Greek news outlets broadcast footage of office workers gathered on the streets of the capital, exchanging bewildered looks and tapping away at their cellphones.

But experts warned that those seeking safety should move to open areas.

“Standing outside a building is not a good idea,” Efthymios Lekkas, the head of the national earthquake planning and protection agency, told Greek television. “It is safer for people to stay inside their homes or, if they go outside, they must find an open space.”