Buildings were damaged in several cities when the earthquake hit at around midday local time (17:00 GMT).
The southern province of El Oro was the worst affected and 12 people died there, authorities said.
Northern Peru felt the quake and a 14-year-old girl died in Tumbes, a border province, when her home collapsed.
In Ecuador, Machala and Cuenca were among the cities that suffered damage to buildings and vehicles, as emergency services rushed to help people.
The epicentre was near Balao, about 80km (50 miles) from Ecuador's second-largest city, Guayaquil, where about three million people live.
"We ran from the house," Machala resident Exon Tobar told the BBC. "The ground - it was a very powerful explosion - it made it shake and it made the electric cables, the windows, and everything move. People were in the streets praying because it didn't stop."
President Guillermo Lasso asked Ecuadoreans to remain calm as officials assess the damage.
He also visited a hospital in the city of Machala to meet with some of the injured people.
The government said more than 250 injured people were treated in the town of Pasaje, in El Oro, and nearly all of them were eventually discharged.
Several roads have been blocked by landslides, while several homes, educational buildings and health centres have been damaged, authorities said.
One person was reported killed in the city of Cuenca, in Azuay province, after a wall collapsed onto their car, while three people died when a security camera tower came down on Jambelí Island, in El Oro province.
There have also been reports of the earthquake being felt in several other cities, including Manabi, Manta and the capital Quito.
This is the strongest quake to hit Ecuador since 2016, when nearly 700 people died and thousands were injured.