WELLINGTON, New Zealand — New Zealand on Tuesday began a rescue operation involving hundreds of tourists and residents who remain stranded in the coastal town of Kaikoura after a powerful earthquake cut off train and vehicle access.

The defense force said it started ferrying people out by military helicopter and that a navy ship from Auckland was due to arrive in the area Wednesday morning.

The magnitude-7.8 quake that struck the South Island early Monday left two people dead and triggered a small tsunami. It also brought down rocks and mud that swept across highways and cracked apart roads.

Home to about 2,000 residents, Kaikoura is a popular destination for travelers taking part in whale-watching expeditions or wanting a stopover with mountain views. But the quake knocked out water supplies and sewer systems and left people with no easy way out.

“From all directions, Kaikoura has essentially been isolated,” said Air Commodore Darryn Webb, acting commander of New Zealand’s Joint Forces. “There’s a real imperative to support the town because it can’t support itself.”

Webb said the military was using four NH90 helicopters that could each transport about 18 people at a time out of the town. He said the ship could pick up hundreds of people if weather conditions allowed.

“We’re going to get as many people and belongings out as quickly as we can,” Webb said.

He said the operation could take several days and that if needed, a C-130 military transport plane could drop fuel, water, food and other supplies to the town. He said about five metric tons of supplies were ready to be delivered from Christchurch.

Sarah Stuart-Black, director of the Ministry of Civil Defence and Emergency Management, said the priority was transporting out those people with health issues or with international flights booked. She said 34 people had been airlifted out by noon Tuesday.

She said the community was rallying to help the tourists.

“It’s fantastic that some of the locals in Kaikoura have taken in tourists into their own homes,” she said.

Elsewhere, many people returned to work in the capital, Wellington, after the quake shut down much of the central city Monday. But some buildings remained closed and heavy rain and flooding compounded the difficulties for others.

Strong aftershocks continued to shake New Zealand, rattling the nerves of exhausted residents.

Police said one person died in Kaikoura and another in Mt. Lyford, a nearby ski resort. Several other people suffered minor injuries in Kaikoura, police said.

Prime Minister John Key flew over Kaikoura by helicopter Monday as aftershocks kicked up dust from the landslides below. Cars could be seen lying on their sides and parts of the road were clearly impassable. “It’s just utter devastation,” Key said.

Three cows whose predicament captured the interest of people around the world after they became stranded on a small island of grass in an area ripped apart by the quake were rescued.