BEIRUT, Lebanon — Syrian security forces arrested dozens of people on Monday in a new offensive, their largest foray into a central Syrian city since withdrawing last month, prompting residents to build barricades to block a more ambitious assault, residents said.

Since withdrawing with the military in June, the security forces have occasionally entered Hama, a city that still bears the scars of a ferocious government crackdown a generation ago. But Monday’s incursion appeared to be more extensive, though short-lived, and protesters vowed that they would stop any attempt to retake the city by force.

“People here are ready with rocks,” said Omar Habbal, an activist.

In past weeks, Hama, a city of 800,000 on the corridor between Damascus and Aleppo, has emerged as a symbolic center of the nearly four-month uprising against 41 years of rule by the Assad family. Protests have gathered momentum, with a remarkable demonstration of tens of thousands of people on Friday, and youths have turned out nightly to taunt the government in Aasi Square, which they have renamed Freedom Square.

Though some have described the city as liberated, the city’s administration still functions, and the military remains in force on Hama’s outskirts.

Residents said about 20 military vehicles and several buses carrying armed men in plain clothes arrived in the early morning. As they entered, some of the security forces chanted in support of President Bashar al-Assad; some residents in the streets responded with “God is great,” a religious invocation meant as defiance.

“The whole city woke up to defend against the raid,” Mr. Habbal said.

Activists said some residents threw rocks while others tried to build barricades with whatever was available — burning tires, stones and trash bins.

The security forces carried out dozens of arrests, mainly on the outskirts. One activist put the number at 43, while another said 65, though the estimates seemed to be guesswork. Residents reported gunfire, but the forces soon retreated.

“The security forces entered, then they left quickly,” said a 24-year-old student who gave his name as Abdel-Rahman. Like many, he insisted on partial anonymity. “People are waiting. They can’t control Hama unless they wipe out the people here.”

Accounts were almost impossible to verify, but several activists said residents had begun organizing what amounted to a defense of the city, although to what extent remained unclear. Self-defense committees with dozens of members have begun patrolling some neighborhoods, in part to maintain order with the withdrawal of security forces and in part to prepare for a government attempt to retake the city by force, they said.

After almost disappearing for weeks, more guards were visible at state installations, in particular the headquarters of the ruling Baath Party.

“Security and policemen were standing around every governmental building,” said Abu Muhammad, a 40-year-old Hama activist. “I hadn’t seen them for weeks.”

Some elements of the military’s feared Fourth Division and Republican Guard were also moving toward the city as of Sunday night, said Wissam Tarif, executive director of Insan, a Syrian human rights group. Another activist said they were headed for Idlib, a province in the northwest, where the government has deployed significant forces.

Before Monday, government officials had held up Hama as evidence of what they describe as the leadership’s good will, allowing dissent as long as there is no damage to property. But as has often happened in uprisings across the region, the protests have generated their own dynamics, and Hama is now a quandary for the government.

Its very name evokes the government’s historic brutality. In 1982, in the culmination of a struggle between an armed Islamic opposition and the government, the military stormed the city, killing at least 10,000 people, and the bloodshed has served as a cry in the protests that erupted in mid-March. Given that history, the government has sought to avoid more trouble in Hama, ordering the withdrawal and firing security officials after a particularly bloody day of protests June 3, when as many as 73 people were killed.

“It is hard for the regime to deal with Hama because it is a special case,” said a 36-year-old activist there who gave his name as Mazen. “Hama is boiling.”

The government may hope that protests there eventually lose momentum, but so far, that has not been the case. Any military attempt to retake it runs the risk of great bloodshed, possibly bolstering regional solidarities that have already become a facet of the uprising. In a country of strong local identities, protesters have organized rallies in support of other besieged cities like Dara’a, in the south, and Baniyas, on the coast.

“We’re expecting a big crackdown,” said a 25-year-old member of a local organizing committee in Hama who gave his name as Hammouda.

“If the army enters Hama, it will be the end of Bashar al-Assad as an acceptable president,” he added. “His father’s reputation was made by Hama’s massacre, and it stayed until his death. Bashar is very close to having the same reputation.”

Hwaida Saad and Nada Bakri contributed reporting from Beirut.