A 7.0-magnitude earthquake rocked a mountainous area of China’s western Sichuan province Saturday less than 100 miles from the provincial capital of Chengdu, killing at least 179 people, injuring thousands and leaving tens of thousands of others homeless.

Premier Li Keqiang hurried to the province as Chinese troops picked through ruins to rescue those trapped in collapsed buildings. The earthquake struck at 8:02 a.m. Beijing time, and the epicenter was located just eight miles below the surface in Ya’an county, home to about 1.5 million people.

Aftershocks shook the area for hours, including two with a magnitude of 5. State television played footage from security cameras when the quake hit, showing panicked residents scrambling down apartment stairs and rushing from hospitals and stores into the street, where many remained overnight for fear that buildings would collapse.

The quake took place about 150 miles from Wenchuan county, where a quake in May 2008 left 87,000 people dead or missing. That disaster led to widespread outrage among Chinese who were angry that shoddy building construction, especially of government schools, had contributed to the collapse of buildings and needless deaths of many children.

On Saturday night, Chinese Central Television showed Li on a plane on his way to the area with a map spread before him; troops were also shown digging through the wreckage of homes, and injured people were seen on stretchers. The state news agency, Xinhua, reported that the Ministry of Civil Affairs had dispatched 30,000 tents, 50,000 cotton blankets and 10,000 makeshift beds to the area.

Most of the area was still in disarray, with tens of thousands sleeping outside and bottled water in short supply. Traffic to Baoxing county remained cut off. Cracks were found in the dams of three water reservoirs in Lushan county. A vehicle carrying 17 People’s Liberation Army soldiers to the epicenter fell into a river, and two soldiers died. However, the director of a center housing 60 pandas told CCTV that the pandas were all fine.

Yang Bo, 37, a courier in Lushan, said he was awakened by the shaking of his house. Tiles fell from the roof and a wall collapsed, and he had trouble opening the door. “I thought I would die here today,” he said in a telephone interview. He managed to get out, although without pants or shoes. After he escaped, his bedroom collapsed and his car was destroyed by falling debris.

“I can’t imagine my future,” he said. “I don’t have any hope but to wait for assistance from the government.”

He said that one town, Shuangshi, was cut off by a landslide and rescue workers were having trouble reaching it.

Zhang Zikang, owner of a logistics company in Lushan, said his house was still standing, but with cracks in the walls. He was helping the local government obtain steel tubes to pitch tents for quake victims in the central square. He estimated that about 5 percent of houses had collapsed and that about 90 percent were damaged.

Gao Hengchun, 49, a self-employed driver from Liberation Village in Tianquan county, said he was walking on the street to his nephew’s wedding when the quake struck and saw rocks rolling down the mountainside and tiles tumbling from rooftops. About 100 people had come for the wedding, and his nephew fell down the stairs when the earthquake took place, injuring his ankles. The family had spent almost $1,500 on the wedding. He said, “Luckily, except my nephew, nobody got hurt.”

Gao said that he hadn’t seen any troops coming to help with the rescue. The village committee was building tents out of tarpaulins. “Everyone is so scared and doesn’t dare to go back to spend the night in their houses,” he said.

Zhang Jie and Liu Liu contributed to this report.