A Pacific Ocean earthquake with a 7.0 magnitude shook El Salvador and Nicaragua, an hour after a powerful hurricane hit Nicaragua's Caribbean coast.

The Pacific Tsunami Center, which had earlier feared a tsunami, said the threat had now passed.

The quake came as a hurricane barrelled into the Caribbean coasts of Nicaragua and Costa Rica.

Emergency services in El Salvador said on Twitter there were no immediate reports of damage at a national level.

The 7.0 magnitude quake, initially reported as a magnitude 7.2, was very shallow at 10.3km below the seabed, which would have amplified its effect.

Its epicentre was located about 149km south-southwest of Puerto Triunfo in El Salvador, according to the US Geological Survey.

Nicaraguan President Daniel Ortega declared a state of emergency due to the quake and Hurricane Otto, which landed on the country's southeastern coast earlier in the day.

The Pacific Tsunami Warning Center warned that "hazardous tsunami waves are possible for coasts located within 300km of the earthquake epicentre."

El Salvador's government also said it saw the threat of tsunami waves hitting the coast.

Earlier, the Category 2 hurricane hit land near the southeastern coast of Nicaragua, where thousands had already been evacuated away from vulnerable coastal areas and into shelters.