“You can’t ignore the pirates anymore,” said Mohamed Aden, a clan leader in central Somalia. “They’re getting more and more muscle. They used to invest their money in just boats and going out to sea but now they’re building up their military side.”

Take the elusive and powerful pirate boss Mohamed Garfanji, who surfaced briefly two weeks ago wearing a belt of bullets strapped across his chest in an X and a purple rain jacket to guide a group of foreign journalists to Hobyo, his base of operations. The journalists had been invited by the Galmudug State administration, a clan-based local government trying to gain a foothold in the region. But Hobyo is a fully engulfed piracy community, where 10-year-old boys with Kalashnikovs hang out in the sandy streets and glare at outsiders, and the visit could happen only with Mr. Garfanji’s blessing. During a meeting with Hobyo elders, Mr. Garfanji stuck his head through the door and grunted: “It’s O.K. for you guys to speak to the journalists. And for them to take pictures.” After that, he vanished.

Mr. Garfanji is believed to have hijacked a half-dozen ships and used millions of dollars in ransom money to build a small infantry division of several hundred men, 80 heavy machine guns and a fleet (a half dozen) of large trucks with antiaircraft guns  not exactly typical pirate gear of skiffs and grappling hooks.

While some of his troops wear jeans with “Play Boy” stitched on the seat, others sport crisp new camouflage uniforms, seemingly more organized than just about any other militia in Somalia.

Mr. Garfanji’s original motivation was probably profit, pure and simple  by mustering a formidable force on land, nobody could squeeze him to pay protection fees. But now his associates claim that their pirate army was created to stop Hizbul Islam and the Shabab.

“Sometimes,” explained Fathi Osman Kahir, a pirate middle manager, “you commit crimes to defend your freedom.”