MOGADISHU, Somalia — The calls from an unknown number had been coming for weeks, but Osman, a household-goods trader in the Somali capital’s largest market, disregarded them — until he got the text message.

Residents shop at an open-air market in the Hamarwayne district of Mogadishu, Somalia. (Omar Faruk/For The Washington Post)

“Will you pick up our call? Yes or no. This is the mujahideen,” it said. The mujahideen, the Islamist militants, al-Shabab. He knew right away what they wanted: to capture him in a protection money racket that the extremist group has been expanding across Somalia for years.

“My heart could barely pump blood in that moment,” said Osman, 45, a father of seven, who spoke on the condition that only his first name be used out of fear for his life. “If I don’t pay, they kill me.”

When Osman replied “yes,” he found thatal-Shabab knew the size of his business and even how many containers of goods he imported through the city’s seaport. Don’t lie to us, they told him, we have the manifests from the ships to cross-check.

Interviews with a dozen business owners in Mogadishu reveal al-Shabab’s quickly growing ability to tax the country’s most lucrative businesses, which analysts and former government officials say earns the group tens of millions of dollars per year, which it uses to fund its attacks on government and military targets, as well as on those who refuse to pay up.

In most of rural Somalia, al-Shabab is in firm control and operates a parallel government. It has its own courts, road tolls and tax collection. But that system is spreading into Somalia’s capital, undermining the legitimacy of the U.S.-backed federal government in the only city that government reliably controls.

“It is a very scary situation,” said Somali Finance Minister Abdirahman Beileh. “We have not been able to address it. It is the number one problem in this country.”

The growth of al-Shabab’s tax revenue stands at odds with the federal government’s claims that the insurgency is on its back foot — and in sharp contrast to the U.S. military’s claims that its operations in Somalia are weakening the insurgency.

A spokesman for U.S. Africa Command, John D. Manley, said in an emailed statement that the U.S. military targets al-Shabab’s “financial and collection operations” with airstrikes. He acknowledged that the militant group is “generally successful using threats and violence to intimidate clans and locals into paying taxes.”

The United States, which has about 500 troops in Somalia, says it has conducted nearly 50 drone strikes this year, killing more than 300 fighters. Most analysts put the number of al-Shabab fighters somewhere just short of 10,000, though the true number is hard to discern, as many of the group’s members blend in and out of civilian life.

Al-Shabab, in turn, has carried out more than 850 attacks — from kidnappings to large bombings — across Somalia this year, killing around 1,600 people, according to the Armed Conflict Location and Event Data Project. The U.S. government has long feared that, as in Afghanistan, instability in Somalia could provide international terrorist organizations a base for operations. The Islamic State, which sometimes clashes with al-Shabab over territory, has a small but active branch operating mostly in northeastern Somalia.

While armed conflict besets much of the country, Beileh’s ministry and al-Shabab now compete over the most basic function of governance: to collect revenue and provide services. The government brings in almost $200 million per year, and although al-Shabab takes in only a small fraction of that, it collects from a broader base of businesses. That base now includes the seaport, the government’s most lucrative source of income.

The Somali government is considering a law that would make it illegal to pay taxes to al-Shabab, but traders argue that such a move would put an even greater burden on them. Many complain that the government can barely keep them safe and that criminalizing their payments to al-Shabab would endanger their lives.

Osman and other traders described how, in the past year, al-Shabab has instituted a simple, tiered system for taxing almost all the goods that enter Somalia through Mogadishu’s seaport, stemming from the group’s ability to get ship manifests by threatening shipping agents.

A 40-foot container is taxed at $160, while 20-foot ones cost $100. Although the exact number of traders that al-Shabab taxes isn’t clear, analysts think the group’s new ability to tax imports could add millions to its annual revenue on top of what it collects from business owners. Ahmed Washington, the port’s manager, did not respond to requests for comment.

“When I told [al-Shabab’s tax collector] I had two containers at the port, he called me back and said, ‘No, you have three this month. You have lied to me,’ ” said Hilowle, 48, who has traded in curtains, clothes and footwear at Mogadishu’s Bakara market for 20 years. He was shocked that al-Shabab knew about containers before they even arrived — his third would only reach Mogadishu a few weeks later.

Paying al-Shabab’s taxes is relatively straightforward and happens through banks, mobile money transfers and the age-old “hawala” system of moneylenders prevalent in Somalia and some Middle Eastern countries, the traders said. The money is then redistributed to al-Shabab cells throughout the country.

For the annual “zakah” tax on businesses, the group’s agents often start with huge requests but then negotiate. Both Osman and Hilowle were initially asked for $10,000 in addition to taxes on their imports.

Hilowle’s “tax collector” threatened him and his family, then used one of Hilowle’s close relatives as a middleman to haggle.

“I insisted on $1,000,” Hilowle said. “I told him, ‘If I could afford that kind of money, I wouldn’t have spent one single night in Mogadishu, I would have relocated to the UAE.’ ”

He expects to pay that sum annually, unless his business grows. He transferred the money to a woman whose bank details were given to him by the agent from al-Shabab.

Osman, on the other hand, went to the village of Mubarak, where al-Shabab has its tax collection offices, to settle his dues. The building was small and bare, he recalled, but a long line of tradesmen emanated from it. Inside were two middle-aged men, one of whom had a laptop and an Excel spreadsheet open. They opened a new file for him. He negotiated down to a $3,000 annual tax.

Somali religious leaders have begun chastising those who pay, although they, like the government, can’t offer traders much protection. Sheikh Nur Barud Gurhan, one of the leaders of the Supreme Religious Council of Somalia, was quoted in local media this month as saying that “anyone who pays al-Shabab will be part of the atrocities they commit.”

But those who don’t pay tax to al-Shabab often pay dearly in other ways. One of Mogadishu’s staunchest opponents of al-Shabab’s tax is Gurey Haji Hassan, the owner of what was once the Makka al-Mukarama Hotel, a busy place filled with Mogadishu power brokers on the city’s central thoroughfare.

For years, Hassan had openly expressed his views against paying. And every year since 2013, his hotel was bombed or attacked by al-Shabab. He rebuilt it each time. But after the last attack, in March, in which 25 people were killed, and another at a different hotel the previous November, in which the owner was killed, he has given up on the hotel business but not his convictions.

“If we pay, there will be no solution. If we resist, maybe there will be a solution. I believe this very strongly. I will never stop. We need more people like me, who say no,” he said by phone from Canada, where he was visiting relatives.

The government is largely powerless to prevent business owners from paying al-Shabab, Beileh, the finance minister, acknowledged. Al-Shabab’s tax collectors freely visit the city to iron out discrepancies, such as late payments, multiple traders said.

“This problem is one-of-a-kind. Al-Shabab are Somalis like me or anyone else. They look like me. They are everywhere, and among us,” Beileh said.

With the government struggling to maintain control of Mogadishu, other Islamist groups such as the Islamic State are building footholds across Somalia and replicating al-Shabab’s taxation scheme, as are local gangs in Mogadishu and other cities.

“The Somali people are funding all these groups, but the question is: Do they have a choice?” said Hussein Sheikh-Ali, who served as a security adviser to the current and previous Somali presidents and now heads the Hiraal Institute, a Somali think tank. “People are giving up, throwing their hands in the air. I’m worried. I’m really worried. I think al-Shabab can win the war with this money. We are in no position to question the intentions of the people who pay unless we remove this dilemma they are facing. They do not have freedom to choose right or wrong.”