Six people were killed and 17 others injured when a small group of militants stormed parliament in the restive Russian republic of Chechnya.
Shouting Islamist slogans, three fighters launched a bomb and gun attack as deputies arrived for work, killing two guards and an official.
All three attackers were killed, the Chechen and Russian authorities say.
Deputies inside the building managed to escape by moving to an upper floor. The attack was condemned by the EU and US.
They both pledged to work together with Russia to defeat "terrorism".
Correspondents say the incident in the capital Grozny is a reminder that the region is far from stable.
Last year Moscow declared victory against Chechen separatists and there has been a relative lull in the violence under Ramzan Kadyrov, Chechnya's Kremlin-backed leader.
But the whole North Caucasus is seeing an insurgency led by Islamist rebels, correspondents say.
Militants struck at about 0845 (0445 GMT), attacking policemen guarding the parliament building, Mr Kadyrov told Russian news agency Interfax.
It is believed they arrived at the parliament by car, tailgating vehicles belonging to deputies.
At least one attacker appears to have set off a suicide bomb just before the other two rushed inside, exchanging fire with security guards.
They could be heard shouting "Allahu Akbar" - Arabic for "God is great" - as they ran inside, according to Chechen security sources.
Photos of the aftermath of the attack show heavy damage to at least several rooms at the parliament and bloodstains on the street outside.
A spokesman for the Chechen parliament, Zelim Yakhikhanov, said deputies had feared they would be taken hostage when they heard shooting outside the building.
"We managed to take refuge on the third floor where we stayed until the end of the operation," he told AFP news agency.
Mr Kadyrov said the operation to suppress the attack took between 15 and 20 minutes. The official killed was reportedly the parliamentary bursar.
Six police officers and 11 civilians were wounded, according to Russian prosecutors.
Russian Prime Minister Vladimir Putin said the family of each of the people killed by the attackers would receive compensation of 1m roubles (£21,000, $33,000) while those wounded would receive up to 400,000 roubles.
It is unclear how such a small group of armed men could have penetrated the government building, which is usually heavily guarded.
The pro-rebel news website Kavkaz-Tsentr quoted its own unnamed sources in Grozny as saying they had heard a "powerful" explosion, followed by heavy gunfire for more than 30 minutes.
The city has been sealed off and armoured vehicles were patrolling the streets, it added.
There has been no confirmation of the identity of the attackers.
History of violence
Russian Interior Minister Rashid Nurgaliyev, who was visiting Chechnya when the attack happened, held an emergency meeting with Mr Kadyrov.
He commended the Chechen security forces' response to the attack, saying they had acted "professionally and competently", and describing the attack as "untypical".
The BBC's Tom Esselmont in the Georgian capital, Tbilisi, says this attack is highly reminiscent of those which peaked in the 1990s and then again some five or six years ago.
It shows the battle is far from over and Chechnya is far from being in the secure situation the Russian government would like to see, our correspondent adds
Alexei Malashenko, an analyst at the Carnegie Centre in Moscow, described the attack as "a slap in the face for Ramzan Kadyrov".
"The war is not finished if you can seize the parliament in the centre of the city - all Ramzan's claims of victory over rebels are worthless," the analyst told AFP.
The EU foreign policy chief, Baroness Ashton, was quoted by AFP news agency as saying: "No circumstances can justify the use of terrorist violence and suicide attacks."
US National Security Council spokesman Mike Hammer offered condolences to the families of those who were killed and to those who were wounded.