Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

JAKARTA, Indonesia — ISIS claimed responsibility for a four-hour siege in the heart of Indonesia's capital on Thursday that killed seven people, including five attackers.

The brazen daylight assault also injured 24 people as attackers detonated explosions and waged armed battles with police around a busy shopping area in downtown Jakarta.

ISIS issued a statement through social media saying the group's "soldiers” were behind the attack, which it said targeted Westerners from countries fighting the terror group in Iraq and Syria.

The claim came after several Indonesian officials blamed ISIS for the siege, with Jakarta's police chief naming a regional ISIS figure as the suspected ringleader.

Downtown Jakarta was turned into a battlefield as the attack unfolded. The U.S. Embassy told citizens to "shelter in place," saying later that no Americans were caught up in the attack but that "further incidents are possible" and the embassy would be closed on Friday.

#ISIS-linked 'Amaq News Agency reported that the #JakartaAttacks were carried out by ISIS and targeted foreign nationals and security forces -SITE Intel Group (@siteintelgroup) January 14, 2016

The siege began at around 10:45 a.m. local time Thursday (10:45 p.m. Wednesday ET) at a busy intersection near a police station and a Starbucks, according to Jakarta police spokesman Col. Muhammad Iqbal.

Photos: Gunfire and Blasts Rock Jakarta

“I was riding a motorbike when suddenly the explosion went off at the police post,” eyewitness Eliaz Warre told The Associated Press. “I saw people running away and two people lying on the ground bleeding. I also saw two people on a motorbike with a back pack and they are the guys who threw the bomb."

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

A policeman stands guard in front of the blast site. Oscar Siagian / Getty Images

A gun battle broke out between the attackers and anti-terror police squads, and gunfire could be heard more than 1½ hours later. Witnesses described seeing bodies in the streets as heavily-armed security forces were deployed.

United Nations official Jeremy Douglas was working from the organization’s building near the scene when shots erupted.

“You could hear a gun fight in the street," he told NBC News. “There were a lot of panicked people running towards our building and staff in my office were pretty freaked.”

A customer at the Starbucks was wounded, the company said, adding that all its stores in the city were being closed as a precaution.

"The Starbucks cafe windows are blown out. I see three dead people on the road," Reuters quoted one of its photographers as saying.

More than four hours after the attacks erupted, Indonesian authorities said all five assailants had been killed and security forces were in control.

Two civilians — including a Canadian national — died in the siege, according to Indonesia's foreign ministry.

It said twenty-four people also were wounded, including five police officers and four foreigners: an Algerian, an Austrian, a German and a Dutch national who was undergoing emergency surgery at the hospital.

Indonesia's president Joko Widodo cut short a trip to Java to return to the capital as the events unfolded; world leaders quickly condemned the attack and expressed support for the nation.

"These acts of terror are not going to intimidate nation-states from protecting their citizens," U.S. Secretary of State John Kerry told reporters in London. "There is nothing in any act of terror that offers anything but death and destruction. And so we stand together, all of us, united in our efforts to eliminate those who choose terror."

Soldiers man armored vehicles near the site of the attacks in Jakarta, Indonesia Thursday. Achmad Ibrahim / AP

Shortly before ISIS claimed responsibility, Jakarta's police chief Tito Karnavian told reporters that an ISIS-linked cell operating in Southeast Asian nations was the "gang" behind the attack.

"There's a militant named Bahrun Naim who wants to be the leader of the region," As he said. "All leaders [of ISIS] in Southeast Asia are competing to be the chief. That's why Bahrun Naim plotted this attack."

He said on television that "our country, nation and the people must not be or and defeated by the terror attack like this.”

Indonesia, the world's most populous Muslim nation, was named in a list of potential global targets by ISIS in the September issue of its official magazine, Dabiq, and the country has been the victim of several attacks in the past claimed by Islamic militant groups.

Last month, anti-terror police in the country arrested nine men and said ISIS had wanted to "perform a 'concert' to attract international news coverage of their existence here,” according to Reuters. Police cited a document seized from the group that described the planned attacks as a "concert."

Thursday's attack was the most serious in Jakarta since the July 2009 bombing of the JW Marriott and the Ritz-Carlton hotels, according to Anton Alifandi, principal terror analyst at IHS Country Risk.

"In the past several years, militants have carried out a number of small-arm attacks targeting the police but today’s is notable for the targeting of an international commercial brand, indicating increased risk of attacks against such targets," he said. "The location of the attacks is significant as it indicates the continuing terrorist capability to perpetrate attacks in the heart of the capital."

Ed Flanagan reported from Beijing, Alastair Jamieson reported from London.