In Pictures: New Zealand rocked by powerful earthquake
A powerful magnitude-7.1 earthquake shook New Zealand's South Island early today.
The prime minister said it was a miracle no one was killed.
Only two serious injuries were reported from the quake, which shook thousands of people awake when it struck at 4.35am near the southern city of Christchurch.
There were reports of some people trapped inside damaged buildings - though none appeared to be crushed by rubble - and a few looters broke into some damaged shops in the city of 400,000, officials said.
Power was cut across the region, roads were blocked by debris, and gas and water supplies were disrupted, Christchurch Mayor Bob Parker said.
Chimneys and walls of older buildings were reduced to rubble, and Parker warned that continuing aftershocks could cause masonry to fall from damaged buildings.
"We're all feeling scared - we've just had some significant aftershocks," he told TV One News. "Tonight we're just people in the face of a massive natural disaster, trying to help each other ... and we're grateful we haven't lost a life."
State geological agency GNS Science reported 29 aftershocks in the 14 hours following the quake, ranging in strength from magnitude 3.7 to 5.4.
A state of emergency was declared and army troops were on standby to assist after the quake, which was centred 19 miles west of Christchurch, according to GNS Science. No tsunami alert was issued.
Prime Minister John Key, who flew to Christchurch to inspect the damage, said it was "an absolute miracle" that no one had died.
As evening approached and a damaged historic building near the city centre burst into flames, officials ordered residents to stay in their homes until Sunday morning. Parker said the curfew would help prevent people from going near about 120 inner-city buildings that were badly damaged.
Up to 90 extra police officers were flying to Christchurch to help, and troops were likely to join the recovery effort on Monday, he said.
Rescue workers also set up accommodation centres at schools in suburban areas to house hundreds of people forced out of their damaged homes, civil defence spokesman Murray Sinclair said.
Suburban dweller Mark O'Connell said his house was full of smashed glass, food tossed from shelves, with sets of drawers, TVs and computers tipped over.
"We were thrown from wall to wall as we tried to escape down the stairs to get to safety," he said.
Sheep farmer Paul Cowie from the town of Darfield, near the quake's epicentre, said his family was knocked to the floor.
"We couldn't stand up, but we had to run across the house to get to the kids ... and they were shaken up," he said. The family fled the house and huddled in a car parked in an open field.
GNS Science initially reported the quake as magnitude 7.4, but later revised it to 7.1. The US Geological Survey measured it at 7.0.
Minister of Civil Defence John Carter said there was "a lot of damage to our key infrastructure ... water, waste water systems."
Experts said the low number of injuries reflected the country's strict building codes.
"New Zealand has very good building codes ... (that) mean the buildings are strong compared with, say, Haiti," which suffered widespread damage in a magnitude-7.0 quake this year, earth sciences professor Martha Savage said.
"It's about the same size (quake) as Haiti, but the damage is so much less. Though chimneys and some older facades came down, the structures are well built," said Savage, a professor at the School of Geography, Environment and Earth Sciences at Victoria University in the capital, Wellington.
Christchurch fire service spokesman Mike Bowden said a number of people had been trapped in buildings by fallen chimneys and blocked entrances, but there were no reports of people pinned under rubble. Rescue teams were out checking premises.
Christchurch Hospital said it had treated two men with serious injuries and a number of people with minor injuries.
One man was hit by a falling chimney and was in serious condition, while a second was badly cut by glass, hospital spokeswoman Michele Hider said.
Christchurch police reported road damage in parts of the city and cordoned off some streets where rubble was strewn about. Parked cars were crushed by heaps of fallen bricks, and roads buckled.
Civil defence agency spokesman David Millar said at least six bridges had been badly damaged and the historic Empire hotel in the port town of Lyttelton was "very unstable" and in danger of collapse. Several wharves at the port were damaged.
People in the city's low-lying eastern suburbs were told to be ready to evacuate after power, gas, sewage and water systems were cut by the quake, Police Inspector Mike Coleman said.
Kiwirail rail transport group spokesman Kevin Ramshaw said 13 trains, mostly freight, had been halted, with some damage confirmed to lines north of Christchurch.
Christchurch International Airport was closed as a precaution as experts checked runways and terminal buildings, a spokesman said.
New Zealand sits above an area of the Earth's crust where two tectonic plates collide. The country records more than 14,000 earthquakes a year - but only about 150 are felt by residents. Fewer than 10 a year do any damage.
New Zealand's last major earthquake registered magnitude 7.8 and hit South Island's Fiordland region on July 16, 2009, moving the southern tip of the country 12 inches closer to Australia, seismologist Ken Gledhill said at the time.