MINNEAPOLIS—Abdi Mohamed strode into a coffee shop on a recent morning and took a lap around the place, shaking hands with about a dozen men as they paused their lively discussions of the news of the day to give him a warm greeting.

“This is our place,” he said of the Starbucks in the Seward neighborhood, where thousands of Somalis live. “This might be the loudest Starbucks in the United States.”

Mr. Mohamed, who immigrated here from Somalia nearly two decades ago, is clearly a member of the group, though he works for the Hennepin County Sheriff’s Office. His job as a full-time liaison to the Somali community includes ample cups of coffee and handshakes in hopes of picking up gossip here and there while fielding questions from local East Africans about law enforcement and the court system. He was tapped for the liaison job because of his contacts and his ability to connect with people, “I was very knowledgeable with what was going on in the community,” he said.

It is a job that grew out of crisis nearly a decade ago when the sheriff said he was caught completely unaware that some two dozen Somalis began leaving Minnesota to join the Islamist extremist group al-Shabaab. And it was tested again this past week, as six young Somalis from Minnesota were arrested for allegedly conspiring to travel to Syria and join Islamic State, the militant group known as ISIS.

“Shame on us for not knowing,” said Sheriff Richard Stanek, who took office just months before the initial, high-profile al-Shabaab exodus. “Community engagement was born out of necessity.”