SAYADA, Tunisia – This Mediterranean fishing town, with its low, whitewashed buildings and sleepy port, is an unlikely spot for an experiment in rewiring the global Internet. But residents here have a surprising level of digital savvy and sharp memories of how the Internet can be misused.

A group of academics and computer enthusiasts who took part in the 2011 uprising in Tunisia that overthrew a government deeply invested in digital surveillance have helped their town become a test case for an alternative: a physically separate, local network made up of cleverly programmed antennas scattered about on rooftops.

The State Department provided $2.8 million to a team of U.S. hackers, community activists and software geeks to develop the system, called a mesh network, as a way for dissidents abroad to communicate more freely and securely than they can on the open Internet. One target that is sure to start debate is Cuba; the U.S. Agency for International Development has pledged $4.3 million to create mesh networks there.

Even before the network in Sayada went live in December, pilot projects financed in part by the State Department proved that the mesh could serve residents in poor neighborhoods in Detroit and function as a digital lifeline in part of Brooklyn during Hurricane Sandy.

But just like their overseas counterparts, Americans increasingly cite fears of government snooping in explaining the appeal of mesh networks.

“There’s so much invasion of privacy on the Internet,” said Michael Holbrook, of Detroit, referring to surveillance by the National Security Administration.

“The NSA is all over it,” he added. “Anything that can help to mitigate that policy, I’m all for it.”

Since this mesh project began three years ago, its original aim – foiling government spies – has become an awkward subject for U.S. government officials who backed the project and some of the technical experts carrying it out. That is because the NSA, as described in secret documents leaked by the former contractor Edward J. Snowden, has been shown to be a global Internet spy with few, if any, peers.

“Exactly at the time that the NSA was developing the technology that Snowden has disclosed, the State Department was funding some of the most powerful digital tools to protect freedom of expression around the world,” said Ben Scott, a former State Department official who supported the financing and is now at a Berlin policy nonprofit, the New Responsibilities Foundation. “It is in my mind one of the great, unreported ironies of the first Obama administration.”

Sascha Meinrath, founder of the Open Technology Institute at the New America Foundation, a nonpartisan research group in Washington that has been developing the mesh system, said that his group has had “hundreds of queries from across the U.S.” since the Snowden leaks began.

“People are asking us, how do they protect their privacy?” Meinrath said.

The citizens of Sayada – population 14,000 – are more focused on using the mesh for local governance and community building than beating surveillance since President Zine El Abidine Ben Ali was ousted in 2011, said Nizar Kerkeni, 39, a resident and professor of computer science at the nearby University of Monastir.

The mesh network blankets areas of town including the main street, the weekly market, the town hall and the train station, and users have access to a local server containing Wikipedia in French and Arabic, town street maps, 2,500 free books in French, and an app for secure chatting and file sharing.

The mesh is not linked to the wider Internet, Kerkeni says — a point in his favor when he invites families to connect in this Muslim community. “Some parents ask me if it is safe to connect to the server,” he said. “They don’t allow their little children to connect to the Internet. I say, ‘I know it’s safe.’ ”

There are some drawbacks, as communications can slow when signals make multiple “hops” from one router to another, leading some Internet experts to question how large a single mesh could grow. Other experts counter that mesh networks in Europe, including some serving large sections of Berlin, Vienna and Barcelona, have thousands of routers, although they require highly technical skills.

Many of those networks were built to compensate for spotty or nonexistent coverage by corporate Internet providers. A similar motivation is at work in some Detroit neighborhoods, where the State Department financed trial runs of mesh networks as a low-cost gateway to wireless Internet access and as a community organizing tool.

But privacy issues also provoke intense discussion, particularly among groups that have historically been targets of racial and other profiling, said Diana J. Nucera, the community technology director at an organization called Allied Media Projects, which has already helped several Detroit neighborhoods put up mesh networks.

“I don’t want the NSA, the government, anyone to necessarily know how I think about something,” Holbrook, an African-American who is a Detroit social and political activist, said at a workshop led by Nucera.

Residents of the Brooklyn neighborhood of Red Hook found that the mesh was useful during a natural disaster. Red Hook, which is dominated by public housing, was one of New York’s most exposed neighborhoods when Hurricane Sandy struck the coast in October 2012.

By chance, two activists, J.R. Baldwin and Tony Schloss, had been trying to create a mesh network in Red Hook. They had set up a router atop a community center run by the Red Hook Initiative, where Schloss worked as a technologist, and managed to connect it to a second one in an apartment overlooking Coffey Park, a local gathering point a few blocks away.

As the storm struck, standard Internet and cellphone networks collapsed across nearly all of Red Hook. But the mesh stayed up.

Hearing about the work, the Federal Emergency Management Agency installed a satellite Internet connection at the community center, using the mesh to spread Internet access to the park, a center for relief efforts. Residents relied on the mesh to get emergency updates and connect with people outside the city. About 25 routers are now in place, Schloss said.