Four gunmen with pistols stuffed into their socks attacked a luxury hotel frequented by foreigners in Afghanistan’s capital Thursday, just hours after militants killed 11 people in an assault on a police station in eastern Afghanistan.

The assailants — who were all killed in both standoffs — made their point, however: Afghan forces face a huge challenge in securing upcoming elections in what will be a major test of their abilities as foreign troops wind down their combat mission at the end of this year.

The attacks show the Taliban are following through on their threat to use violence to disrupt the April 5 vote, which will be the first democratic transfer of power since the 2001 U.S.-led invasion that ousted the Islamic militant movement. President Hamid Karzai is constitutionally barred from seeking a third term.

Taliban spokesman Zabihullah Mujahid claimed responsibility for the assault on the Serena hotel and the earlier attack in Jalalabad, an economic hub near the border with Pakistan.

“Our people, if they decide to attack any place, they can do it,” he said.

The violence began before dawn Thursday when a suicide bomber blew up his explosives-laden car outside the police station in Jalalabad, near the palatial residence of Nangarhar provincial Gov. Attaullah Ludin.

Six gunmen rushed into the station as two more bombs exploded nearby — one hidden in a motorized rickshaw and another in a vegetable cart.

That prompted a fierce battle that lasted more than four hours, with Afghan police and soldiers chasing gunmen down the street amid gunfire and smoke billowing into the blue sky. Security forces killed seven attackers, deputy Interior Minister Gen. Mohammad Ayub Salangi said.

Police said the attack killed 10 officers, including a city district police chief, and a university student caught in the crossfire, and wounded 15 policemen.

The initial suicide bombing badly damaged the nearby state-run Afghan radio and television building, shattering its windows.

The Taliban have carried out numerous attacks in Jalalabad, Kabul and elsewhere in the east. But the choice of a police station as a target reflected an effort to show they can still penetrate heavily secured areas despite numerous U.S. and Afghan offensives against them in recent years.

Hours after the police station, four young men entered the Serena hotel — considered one of the safest places to stay in Kabul — at about 6 p.m., telling guards they were going to dinner, officials said. To enter the hotel, guests must pass through an exterior gate and undergo a metal detector search and pat down.

Inside they drew the pistols hidden in their socks and opened fire, Interior Ministry spokesman Sediq Sediqqi said. Bursts of gunfire could be heard from outside the hotel as Afghan troops cordoned off the area.

The attackers appeared to be about 18 years old and all had been killed, Sediqqi said, adding that gunfire wounded two hotel security guards.

In a separate statement, Mujahid said the gunmen targeted foreigners and dignitaries gathered at the hotel for a celebration marking the Persian new year, Nowruz. He said Thursday’s attacks in Kabul and Jalalabad show the vulnerability of government forces against determined militants.

Afghanistan’s upcoming elections include provincial votes, but the most closely watched is the presidential race. Karzai’s successor will guide the country for the next five years as most U.S. and allied forces leave the country by the end of 2014.

As part of the withdrawal process, Afghan authorities on Thursday released dozens of prisoners who had been held by foreign troops, including about 40 who had been detained by British forces in southern Helmand province, officials said.