There was no immediate word on whether there were any injuries or damage in the nearby areas, which are not densely populated.
The USGS said the quake was centred about 41 kilometres (25 miles) northeast of Puerto Obaldia, Panama. The epicentre was at a depth of 10 kilometres (6 miles). An aftershock with a magnitude of 4.9 followed about 10 minutes after the original quake.
Panama’s civil defense agency said via Twitter that the earthquake was felt in the provinces of Darien, Panama, Guna Yala and West Panama. “There is no report of effects,” it said. A short time later, it said Panama’s National Emergency Operations Center had ruled out the possibility of a tsunami.
The temblor was felt in some parts of Panama’s capital, but not in others. Residents in the Colombian cities of Medellin and Cali also felt shaking.
The region shaken is home to the Darien Gap, a sparsely settled area of dense jungle that is a primary land route for migrants heading north out of South America. Hundreds of thousands of migrants have passed through in recent years.