TUNIS — An explosion tore through a bus carrying members of the president’s security guard through the heart of Tunisia’s capital on Tuesday evening, killing at least 12 people and prompting the president to declare a 30-day state of emergency.

In a statement, President Béji Caïd Essebsi, who was not near the site of the explosion, called the blast a “cowardly terrorist attack.” He canceled a scheduled trip to Switzerland and announced a nightly curfew beginning at 9 p.m. The Tunis airport and tourist sites were closed after the explosion, according to news reports.

Mr. Essebsi said that in addition to the dead, 20 members of the presidential guard had been wounded. There was no immediate claim of responsibility.

The blast was the third major attack by militants in Tunisia this year and the first serious assault on the security forces in Tunis since jihadists began a campaign of violence in 2011. It occurred on Mohammed V Avenue, near Avenue Habib Bourguiba, the city’s storied commercial thoroughfare and the location of the headquarters of the Ministries of Interior and Tourism, along with other important landmarks.