Costa Rica President Laura Chinchilla announced there were no reports of major damage and called for calm.
At the epicenter, the beach town of Cangrejal, Jairo Zuniga, 27, said everything in his house fell when the quake hit at 8:42 a.m. (10:42 a.m. EDT; 1442 GMT).
"It was incredibly strong. I've felt earthquakes, but this one was 'wow,' he said.
The U.S. Geological Survey said the quake was centered about 38 miles (60 kilometers) from the town of Liberia and 87 miles (140 kilometers) west of the capital, San Jose, where frightened people ran into the streets.
The magnitude initially was estimated at 7.9, but was quickly downgraded. Local residents said it shook for about 30 seconds and was felt as far away as neighboring Panama and Nicaragua, where school was canceled in some areas.
Officials initially warned of a possible tsunami, and local police supervisor Jose Angel Gomez said about 5,000 people — 80 percent of the population — had been evacuated from coastal towns in the Samara district west of the quake's epicenter. But by mid-day they were allowed to return.
Panama also briefly called for people to evacuate beach areas.
In Costa Rica, one man died of a heart attack caused by fright, said Carlos Miranda, a Red Cross worker in the city of Liberia.
Hospitals near the epicenter reported their facilities were overwhelmed by the number of people seeking treatment (for what? Injuries or for panic? Don't know).
Douglas Salgado, a geographer with Costa Rica's National Commission of Risk Prevention and Emergency Attention, said officials a landslide hit the main highway that connects the capital of San Jose to the Pacific coast city of Puntarenas, and hotels and other structures suffered cracks in walls and saw items knocked off shelves.
Rosa Pichardo, 45, who lives in Samara, was walking on the beach with her family when the quake hit.
"When we felt the earthquake, we held onto each other because we kept falling," Pichardo said. "I've never felt anything like this. We just couldn't stay standing. My feet gave out under me. It was terrible, terrible."
In the town of Hojancha a few miles (kilometers) from the epicenter, city official Kenia Campos said the quake knocked down some houses and landslides blocked several roads.
"So far, we don't have victims," she said. "People were really scared ... We have had moderate quakes but an earthquake (this strong) hadn't happened in more than 50 years."
Michelle Landwer, owner of the Belvedere Hotel in Samara, north of the epicenter, said she was having breakfast with about 10 people when the earthquake struck.
"The whole building was moving, I couldn't even walk," Landwer said. "Here in my building there was no real damage. Everything was falling, like glasses and everything."
In the coastal town of Nosara, roughly 20 miles (30 kilometers) southwest of the epicenter, trees shook violently and light posts swayed. Teachers chased primary school students outside as the quake hit. Roads cracked and power lines fell to the ground.
Wednesday's quake occurred in a seismically active zone where the Pacific tectonic plate is diving beneath Central America.
"All along the Pacific coast of Central America, you can expect fairly big earthquakes," said seismologist Daniel McNamara of the U.S. Geological Survey.
The quake was fairly deep — 25 miles (41 kilometers) below the surface. Deeper events tend to be less damaging than ones closer to the surface, but more widely felt.
"If it was a shallower event, it would be a significantly higher hazard," he said.
The last deadly quake to strike Costa Rica was in 2009, when 40 died in a magnitude-6.1 temblor. The last similar-sized quake to hit the country was in 1991 when 47 people were killed in the Limon-Pandora area.
Associated Press writers Jack Chang, E. Eduardo Castillo , Santiago Torrado and Anita Snow contributed to this report from Mexico City and Cesar Barrantes from San Jose, Costa Rica. AP Science Writer Alicia Chang contributed from Los Angeles.