Police have arrested a local man over the attack in which Elmar Veliyev, mayor of the northwestern city of Gyanja, was shot and wounded in front of his office on July 3.
Interior Ministry officials say the suspect, Yunis Safarov, has ties to a militant group that wants to establish Islamist rule in Azerbaijan, a secular state where most people are Shi'ite Muslims, and that he trained with militants in Syria. They have cited no sources for the information.
But some Gyanja residents challenge the ministry's version of events. They suggest Safarov was motivated by revenge for what they see as Veliyev's mistreatment of Gyanja residents and disrespect for their religious views.
In a rare outbreak of violence against officialdom in the South Caucasus nation, two police officers were stabbed to death in clashes when a protest over Safarov's arrest and unofficial reports that he was beaten in custody turned violent on July 10. A third, Samir Bayramov, was wounded.
Azerbaijan, a majority Muslim country of about 10 million, has grown wealthy from oil and natural gas since it declared independence from the Soviet Union in 1991. Protests are rare and are put down quickly.
But while money has flowed into sprucing up Baku, opponents of President Ilham Aliyev say few have seen major benefits from the oil wealth, especially people outside the capital, and accuse his government of suppressing human rights and stifling democracy.
Drawing parallels with Aliyev, they accuse Veliyev, 57, of treating Gyanja like a personal fief, showing no regard for the city's poor and being high-handed with anyone who stands in his way.
"Veliyev has been behaving exactly the same way as Aliyev does," Jakhangir Amirkhanly, a 74-year-old member of the opposition Musavat Party, told Reuters in Gyanja.
The unrest was brief and there is no sign of it spreading. Aliyev, who succeeded his father Heydar Aliyev as president in 2003, brooks little dissent and the opposition is weak.
The municipal authorities in Gyanja said in an emailed response to Reuters' questions that criticism of Veliyev was "groundless and biased."
But the events in the city show that, with the economy heavily dependent on the energy sector and the wealth gap now huge, Azerbaijan's leaders could face a growing challenge to retain power in the long term if oil prices fall.
Deeply entrenched elites and long-term rulers in other countries in the region are watching closely -- Kazakhstan, Russia and Turkmenistan all have economies that are reliant on energy and leaders who are nervous about any signs of unrest.
Europe is also watching. Because of its energy reserves and strategic location along the Caspian Sea, Azerbaijan is seen by Europe as an important alternative to Russian energy supplies, and BP is a major investor in the country.
"ACTS OF TERRORISM"
Aliyev has shown his concern by taking charge of the investigation into the events in Gyanja, which he has described as acts of terrorism and crimes against Azeri statehood aimed at intimidating society.
The authorities also showed their nervousness by trying to stop news of the protest spreading, city residents said. For two days afterwards, mobile telephone data services were turned off in Gyanja, making it hard to access social media, they said.
Some had used Facebook to circulate information about the events and the prosecutor's office has opened criminal cases against the editors of four independent Azeri websites that re-posted their entries.
Gyanja, a city of 330,000, has been administered for seven years by Veliyev, a member of the ruling party who was appointed by Aliyev.
Police say four people accused of links to radical religious organizations were killed in sting operations after the assassination attempt and protest. In addition, 61 have been arrested and charged, and 13 others are wanted by police.
But of 11 Gyanja residents who agreed to speak to Reuters about the events, eight doubted the assassination attempt had any link to militant Islamists and said they believed Veliyev, who is a Muslim, was attacked because he was unpopular.
None wanted to be identified for fear of reprisals except Amirkhanly, though Azeri officials deny Western charges of repressing and intimidating opponents.
"We were shocked that someone dared to take a gun and shoot the mayor," a pensioner said in a Gyanja park, lowering her voice and looking round to make sure no one was eavesdropping.
"But honestly, no one was particularly worried because Veliyev did a lot of bad things in our city ... The rich became richer and the poor became beggars," she said.
The city administration in Gyanja defended Veliyev's record in office in response to Reuters' questions.
"The attack ... is just a terrorist act. It's not connected to any particular motives, revenge or response to the supposed 'social tyranny' by Veliyev," it said.
"Large-scale construction work has been carried out in the city. The authorities have had meetings with city residents, listened to their complaints and dealt with them effectively."
LESSONS TO BE DRAWN
Pot-holed roads and some old buildings have been repaired in Gyanja, shopping malls have been built and a four-star Ramada Plaza hotel has been erected. The city center is dominated by a vast park named after Heydar Aliyev, who was president from 1993 until 2003.
But Amirkhanly said: "Unemployment is very high and the majority of young residents of Gyanja emigrate to Russia or Turkey."
An 84-year-old pensioner who declined to be named said he had been tricked by the city authorities into leaving his flat in a run-down building while it was repaired.
The authorities reneged on a promise to pay for his and others' temporary accommodation and are now trying to persuade them to cede ownership of the flats to a construction firm that wants to demolish them and build on the site, he said.
The pensioner said he had managed to meet Veliyev to petition him over the property, but the mayor "was very rude".
The mayor's office did not respond directly to the pensioner's remarks but said it had "no evidence of Elmar Veliyev having an unlawful attitude towards citizens".
Aliyev's supporters say he has brought stability to Azerbaijan, modernized the country and forged closer ties with Europe since succeeding his father in 2003.
He won a fourth successive term in April with more than 85 percent of votes but the election was boycotted by the main opposition and its legitimacy was questioned by independent observers.
Signs of public anger have flared in recent years. Protests in Baku in 2011, by crowds demanding Aliyev and his government quit, ended after a security crackdown and mass arrests.
In 2016, protests broke out in at least three cities -- Quba, Siyazan and Shabran -- over rising bread prices and a sharp devaluation of the manat currency as oil prices fell. Police responded with widespread arrests, residents said.
The unrest in Gyanja has also been contained.
"There is no organized opposition political force in the country that can compete with the ruling elite," said Ilgar Velizade, an independent political analyst. "But the authorities should draw some lessons from the recent events and reconsider their personnel policies, pay more attention to social problems and communicate more with people."
A $38-billion sovereign wealth fund has been set up to ease the pain of any economic downturn. Foreign donors have also urged Baku to diversify the economy to make it less dependent on oil and gas, which make up about 75 percent of state revenues.
There is little sign of it doing so, with the government expecting 2 percent growth this year after only 0.1 percent in 2017 and a 3.8 percent contraction in 2016.
The status quo may suit the West as stability helps it "implement global energy projects in the region," Velizade said.
The European Union's efforts to reduce reliance on Russian gas depend partly on developing the so-called Southern Gas Corridor, which is expected by 2020 to bring about 16 billion cubic meters of gas a year to Europe via Georgia and Turkey from Azerbaijan's Shah Deniz field.
(Reporting by Reuters staff; Editing by Timothy Heritage)