SEOUL, South Korea — South Korea’s prime minister was pelted with eggs and water bottles by angry villagers on Friday as he paid a visit to the rural county chosen as the site of a planned United States missile defense system.

The visit by Prime Minister Hwang Kyo-ahn to Seongju, about 135 miles southeast of Seoul, the capital, was meant to defuse continuing opposition to the missile range. Instead, he was forced to retreat as thousands of residents who had gathered in front of Seongju’s government headquarters shouted, “Go away!” according to television footage.

Facing the crowd, Mr. Hwang said South Korea needed the Terminal High-Altitude Area Defense system, or Thaad, to defend against North Korean missiles.

He also apologized for not having explained the rationale for the deployment before the county, which has a population of about 50,000, was named as the site for the missile base on Wednesday.

Residents, many of them melon farmers, fear that the presence of the powerful radar system will threaten their health and their crops — fears that the government said were groundless. The government also promised economic aid to help assuage concerns that a new military base would undermine the local economy.

None of these assurances appeased residents on Friday.

Confronted with a barrage of eggs, water bottles and boos, Mr. Hwang was forced to duck behind shields and umbrellas raised by bodyguards and retreat into the government building. Some people threw salt, a practice that rural South Koreans believe helps dispel evil spirits.

Later, protesters blocked a minibus carrying Mr. Hwang and his entourage when it tried to leave through a back gate. They also parked a large tractor in front of the minibus. Scuffles erupted during a standoff between the police and demonstrators that lasted for hours. No major injuries were reported.

Some people also refused to send their children to school in protest.

The rally came a day after President Park Geun-hye appealed for an end to an “unnecessary debate” over the planned deployment.

Since Wednesday, activists have held small demonstrations in front of the Defense Ministry building in Seoul to protest or support the missile system.

In a survey published on Friday by the polling company Gallup Korea, 50 percent of 1,004 respondents said they supported the deployment, while 32 percent said they opposed it.

The American and South Korean militaries hope to install the Thaad battery in Seongju by late 2017.

According to the poll, those who supported the deployment said it would help protect South Korea and American forces in the country from the North’s ballistic missiles and nuclear weapons. Those who opposed the plan said they doubted the effectiveness of Thaad as a defensive weapon or feared that it would only deepen the country’s dependence on the American military and raise tensions with neighboring countries.

China, South Korea’s top trading partner, angrily opposed the deployment, saying that it, not the North, was the system’s primary target. Russia, too, contended that the deployment would compromise its security. North Korea has sworn an unspecified “physical counteraction.”

A version of this article appears in print on , on Page A4 of the New York edition with the headline: South Koreans Pelt Premier With Eggs Over Missile Site. Order Reprints | Today’s Paper | Subscribe