Suicide bombers and grenade-wielding gunmen affiliated with Islamic State caused mayhem in the world's most populous Muslim nation Thursday by setting off a series of midmorning explosions in the heart of Indonesia's crowded capital, but fell short of inflicting the extensive death toll witnessed in other attacks.

Two civilians were killed along with five assailants, who detonated suicide bombs and lobbed crude grenades near the Sarinah shopping mall, police posts and a Starbucks in central Jakarta. Officials said two attackers blew themselves up and three others were killed in gun battles with police.

At least two surviving attackers were arrested, police said.

Islamic State, the militant organization based in Iraq and Syria, claimed responsibility for the attack in an online statement, saying its operatives targeted citizens of a "crusader alliance" — an apparent reference to Western countries, according to Rita Katz, director of the SITE Intelligence Group, which monitors extremist organizations.

Jakarta Police Chief Tito Karnavian said at a news conference that the attack was carried out by a network with "links to Islamic State."

Indonesian officials said a Canadian national was killed, and an Austrian, a German and a Dutchman were among about 20 injured. But the toll could have been much higher, analysts said.

"They could have gone inside the mall and started shooting," said Yohanes Sulaiman, an Indonesian political analyst. "Instead they decided to attack the police post, which is pretty stupid when you think about it."

By comparison, 130 people died in the Nov. 13 attack in Paris that was carried out by at least seven heavily armed gunmen and suicide bombers loyal to Islamic State. Nasir Abbas, a former terrorist who now assists Indonesian police, called the Jakarta assault a "copycat" of the Paris attack.

Still, the first significant terrorist attack in Jakarta in seven years brought to life the fears of officials in this moderate Muslim nation that Islamic State backers would launch attacks here. Security experts have warned that Indonesian citizens who left to join Islamic State could return home and carry out attacks, just as some Indonesian extremists did after enlisting with Al Qaeda in the 1980s to fight and train in Afghanistan.

It also raised concern about the widening reach into southern Asia of radicals who are inspired by Islamic State, even if not directly connected to the group. Loyalists have claimed responsibility for deadly attacks in recent weeks in Bangladesh and Afghanistan, and several Indians have been arrested on suspicion of trying to join the group.

Sidney Jones, director of the Institute for Policy Analysis of Conflict and a leading expert on terrorism in Indonesia, has estimated that 250 to 300 Indonesians are fighting alongside Islamic State in Iraq and Syria, fewer than the number coming from many smaller, non-Muslim countries.

Jones, in a paper released this month, said there was little indication that any had returned to foment violence at home.

"The threat would rise significantly if Indonesian ISIS commanders or ISIS central decided to send a few combat-hardened fighters home with the specific mission to organize and train local groups, but so far, that does not appear to have happened," Jones wrote, referring to the militant group by an acronym.

Indonesian authorities named the mastermind of the Jakarta attack as Bahrun Naim, an Indonesian in Syria with Islamic State.

The attack came after authorities arrested nearly two dozen suspected Islamic State supporters in December and January, mainly on the island of Java, saying they were planning coordinated attacks on New Year's Eve. Before that, Islamic State had threatened the lives of top Indonesian police officials.

Ken Conboy, a security consultant in Jakarta, said the arrests may have prompted other members of the network to rush to stage Thursday's attack without substantial training or planning.

"I would guess that there is some linkage between all these arrests and the attacks that took place today," he said. "I suspect that police were closing in on the remnants of the cells."

Leigh Dixon, a partner with the Jakarta-based risk analysis firm Concord Consulting, said the investigation is likely to focus on how the attackers acquired the homemade grenades and how they organized without being discovered by police.

Had they used more powerful, military-grade grenades, the damage would have been far greater, Dixon said, although the attack made news around the world.

"If the result you want is media publicity for the cause, they are certainly getting it," Dixon said. "That they killed so few people is incredibly lucky."

Witnesses reported about five explosions, including near the Starbucks and in front of the Sarinah shopping mall, around 10:40 a.m. Both are located in the center of a normally buzzing business district in this city of 9 million.

"When I heard the first explosion, I didn't know if it was a bomb," said Aditya, a bank worker in a building near the scene of the attacks, who goes by one name.

"I went outside and in front of Starbucks I saw smoke and two people lying on the ground in a pool of blood."

Police told him to back off, he said, and then he saw a gunman open fire before fleeing the scene, killing a person in a white shirt.

Indonesian President Joko Widodo called for calm and said "the state, nation and people should not be afraid of such terror acts."

Most Indonesians practice a moderate form of Islam, but over the years, extremist groups such as Al Qaeda and Islamic State have attracted a relatively small number of dedicated supporters.

The country's deadliest attack occurred in 2002, when a car bomb exploded outside nightclubs in Bali, killing 202 people, mostly foreigners. Bombings of luxury hotels followed in 2003 and 2009. But a security crackdown had largely kept the extremist movement in check.

The bombings of the 2000s were carried out by Jemaah Islamiyah, a Southeast Asian network affiliated with Al Qaeda that included numerous veterans of the Afghan war against the Soviet Union. The group planned its attacks over long periods of time and aimed for well-known places, such as luxury hotels popular with foreigners.

Compared with those bombings, Thursday's attack was puzzling to experts in its strategy and execution.

"It's too early to say," Conboy said, "but it doesn't look like they were trying to inflict maximum damage."

Special correspondent Paddock reported from Jakarta and Times staff writer Bengali from Mumbai, India. Special correspondent Ahmad Pathoni in Jakarta contributed to this report.