By Tarek Amara

TUNIS (Reuters) - A bomb exploded on a bus packed with Tunisian presidential guards in the capital Tunis on Tuesday, killing at least 12 people in an attack one source said was probably the work of a suicide bomber.

Ambulances rushed wounded from the scene and security forces closed off streets around Mohamed V Avenue, one of the main streets in Tunis, before the president declared a curfew in the city and imposed a state of emergency nationwide.

It was the third major attack in Tunisia this year, after an Islamist militant killed 38 foreigners at a beach hotel in the resort of Sousse in June, and gunmen killed 21 tourists at the Bardo Museum in Tunis in March. Islamic State claimed both those attacks.

"They want to make us live with horror but we are going to bring that horror to the terrorist camps," President Beji Caid Essebsi said in a televised speech. "We are at war and we are going to win."

Security sources said the guards were boarding the bus to be taken to the presidential palace on the outskirts of the city when it blew up. One presidential source said it was likely that a bomber had detonated his explosive belt inside the bus.

At least 12 guards were killed and 17 wounded, according to an Interior Ministry statement.

If confirmed it was a suicide bomber, it would be the first such attack in Tunisia since October 2013 when an attacker blew only himself up on a beach in the resort town of Sousse.

"I was on Mohamed V, just getting ready to get into my car, when there was a huge explosion. I saw the bus blow up. There were bodies and blood everywhere," said bystander Bassem Trifi.

Essebsi canceled a trip to Europe and said Tunis would be placed under curfew until Wednesday 5 a.m. (0400 GMT). He reinstated a month-long state of emergency, temporarily giving the government more executive flexibility, security forces more powers, and restricting some civil rights.

Mohamed V is a major boulevard usually packed with traffic and pedestrians, and the site of several hotels and banks.

Story continues

Fighting Islamist militants has become a major challenge for Tunisia, a small North African country that was hailed as a blueprint for democratic change in the region after an uprising in 2011 ousted autocrat Zine Abidine Ben Ali.

Tunisia has held free elections and is operating under a new constitution and a broad political consensus, for which secular and Islamist parties have managed to overcome deep disagreements.

But several thousand Tunisians have also left to fight in Syria, Iraq and Libya with Islamic State and other militant groups, and some have threatened to carry out attacks at home.

The army has also been fighting against another Islamist militant group in the mountains near the Algerian border. Militants have attacked checkpoints and patrols in rural areas in the past.

In September, the government received intelligence reports pointing to possible car bombings in the capital and banned traffic in parts of the city.

This month, authorities arrested 17 Islamist militants and said they had prevented another major assault, planned for November, on hotels and security forces in Sousse.

(Reporting by Tarek Amara and Mohamed Argoubi; Writing by Patrick Markey; Editing by Kevin Liffey, John Stonestreet and Christian Plumb)