MOGADISHU, Somalia — Three explosions over four days in or near the Somalian capital have left a trail of carnage, killing nearly 20 people and injuring dozens of others, as Islamist militants unleashed a wave of attacks on the country.

On Sunday, a car bomb exploded at a security checkpoint near the Interior Ministry on a road leading to the presidential palace in the capital, Mogadishu. At least three people, in addition to the bomber, were killed, a police chief said.

The blast sent a plume of black smoke billowing above the skyline.

The police chief, Gen. Bashir Mohamed Jama, said that five other people had been injured in the blast and that the authorities had thwarted two other suicide bombing attacks on Sunday morning.

The Shabab, an Islamist extremist group affiliated with Al Qaeda, claimed responsibility for the attack, saying it had killed 13 members of the security forces, although that could not be independently verified.

The group, which has been behind bombings and other attacks in Mogadishu, aims to topple Somalia’s Western-backed federal government.

Earlier on Sunday, another car bomb exploded in Siinka Dheer, outside Mogadishu, but the toll was not immediately clear. Some reports said that one person had been killed, along with the driver.

Mogadishu’s mayor, Abdirahman Omar Osman, also known as Yariisow, condemned the attacks, saying, “These terror acts will not stop us.”

Dr. Abdulkadir Adan, from Mogadishu’s only emergency services unit, said, “Our vehicles and rescue teams immediately reached the Sayid checkpoint to rescue civilian injured at the scene.”