HANOI, Vietnam — Vietnamese officials signaled Saturday that further violence over a dispute with China would not be tolerated, declaring that more than 300 people involved in last week’s attacks on foreign-owned businesses would be prosecuted.

“They have seriously undermined the country’s image, and such action has to be punished,” said Gen. Hoang Cong Tu, head of investigations at the ministry of public security.

In the first official accounting of the damage, he told reporters here in the capital that two Chinese workers had died and 140 were injured.

The outburst of looting and arson that left scores of factories flattened was inspired by China’s deployment of a deep-sea oil rig in disputed waters about 140 miles off Vietnam’s coast.

Unlimited Digital Access. $1 for 4 weeks.

The action by Vietnam’s far bigger northern neighbor and historical foe infuriated the Vietnamese government, which allowed protests to go ahead as a way of showing their displeasure.

But the government was caught by surprise when the protests spread to industrial areas in Ha Tinh province and around Ho Chi Minh City and quickly devolved into violence by Vietnamese workers.

On Saturday, Prime Minister Nguyen Tan Dung sent a text message through the state-run mobile phone company warning citizens not to participate in “illegal protests,” and threatening severe consequences if they did. An earlier message from the prime minister was more equivocal, supporting defiance but calling for an end to unrest.

The government, which has tried to project Vietnam as a safe, low-cost foreign investment opportunity, was rattled by the possibility of losing investors, said an American adviser to foreign companies here.

“This really is an extraordinary development,” said the adviser, who declined to be named for fear of alienating the government. “Malays are supposed to ‘run amok,’ but not Confucian Vietnamese.”

But on the main issue vexing China and Vietnam — the positioning of China’s prized oil rig in disputed waters of the South China Sea — both sides remained entrenched, determined to try to outlast the other.

According to a Vietnamese person, a Chinese armada of navy war ships and coast guard vessels is protecting the oil rig, patrolling inside a 10 mile perimeter. A smaller flotilla of Vietnamese warships and coast guard ships continues to try to push past the Chinese boats.