There were no immediate reports of injuries or damage, according to the fire brigade and local authorities.
The tremor, with a depth of about 10 kilometers, struck around 12:24 GMT in the wider area of Messapia.
"It was felt very strongly... and lasted long," Messapia Mayor George Psathas told Skai radio.
A second tremor followed
Another tremor with a magnitude of 3.6 followed, according to the European-Mediterranean Seismological Centre.
Seismologists told Greek media that the area had been hit by earthquakes about 20 years ago.
Greece is often rattled by earthquakes, most causing no serious damage.