A wall at the University of Costa Rica's school of electrical engineering sustained damage during the earthquake in San Jose, Costa Rica, on Wednesday.

San Jose, Costa Rica - A powerful earthquake rocked Costa Rica on Wednesday, killing at least two people, sparking landslides, knocking down buildings, and briefly triggering a tsunami warning.

Residents of the capital San Jose said phones went down, electricity poles rattled on the streets and water flowed out of swimming pools after the 7.6-magnitude quake.

The Red Cross said two people died. One was a man working on a construction site who was killed when part of a wall fell on top of him. The other was a woman who suffered a heart attack.

Costa Rican television said 22 people were also treated for injuries. The Red Cross could not confirm this.

Locals were shocked by the force of the earthquake, which was felt as far away as Nicaragua and Panama, and the biggest to hit Costa Rica since a 7.6 magnitude quake in 1991 left 47 dead.

“I was inside my car at a stop sign and all the sudden everything started shaking. I thought the street was going to break in two,” said Erich Johanning, a 30-year-old who works in Internet marketing in San Jose. “Immediately I saw dozens of people running out of their homes and office buildings.”

Esteban Moreno, a spokesperson for the national emergency services (CNE), said some buildings near the epicentre in the Pacific region of western Costa Rica had collapsed, though he added they were mostly older, and of poor structural quality.

There were local reports of the earthquake leaving its mark on hotels in the region, though Moreno said he was unaware of any serious damage suffered by tourist resorts.

The CNE said landslides had blocked some roads and that damage was done to some homes in built-up areas in the Nicoya Peninsula on the Pacific coast.

The Pacific Tsunami Warning Centre initially issued a warning for Pacific coastlines of Costa Rica, Nicaragua and Panama, but this was later cancelled. The centre had earlier warned of tsunamis for as far afield as Mexico and Peru.

The epicentre was in western Costa Rica about 140km from San Jose, the US Geological Survey (USGS) said.

The Guanacaste region around the epicentre is known for its beaches, surf and volcanoes. With several nature and marine reserves it is less tropical than the rest of the Central American nation, with stretches of open savannah and mountains.

In the town of Nicoya, 10km from the epicentre, Selenia Obando, a receptionist at the Hotel Curime, said the building was left without lights and power. A floor had collapsed in the hotel but there were no injuries.

“It was horrible, like being in a blender going round and round,” Obando said. “All the water sloshed out of the swimming pool. It's now about half full.”

There was also an early report of damage to the Hotel Riu Guanacaste on Matapalo beach in Guanacaste.

But America Nava, a reservations clerk with Riu in Mexico, said it had only been evacuated. “There is no damage to the hotel, they're checking it to make sure everything is in order. As soon as that is finished, the guests will return.”

Actor Mel Gibson owns a lush forest retreat at Playa Barrigona in Samara not far from the epicentre, which he recently put up for sale for $29.75-million. Guests to the 500-acre property have included Bruce Willis and Britney Spears.

The last serious quake to hit Costa Rica was a 6.1 magnitude quake in January 2009, which killed 40 people. - Reuters