Shortly before dawn, an Azerbaijani on an English course in Hungary crept into the room of a fellow student from arch-enemy Armenia. In a frenzy of ethnic hatred, Ramil Safarov hacked the sleeping Armenian to death with 26 ax blows — nearly decapitating him.

Convicted of murder, the Army lieutenant was sentenced to life in prison, and the lurid case largely faded from memory for nearly a decade.

It rose like a wrathful ghost last month, when Safarov was sent home, pardoned and embraced as a national hero. The affair now threatens to wreck 20 years of international attempts to reconcile the two ex-Soviet neighbors, which fought a war in the 1990s that killed some 30,000 and put a large section of Azerbaijan under Armenian control.

While there's no sign that war is about to erupt again, the Safarov dispute shows genuine peace to be further away than ever.

The tensions worry both Russia and the West, which are jockeying for influence in a region seen as a buffer between Europe and Iran and as a key player in the world oil market.

It all started in February, 2004, when Safarov and Armenian Gurgen Markarian, also a military officer, were living in the same dormitory while attending a NATO-sponsored language course in Budapest.

On a trip to a supermarket to get food and cigarettes, Safarov bought an ax as well.

Two days later, after finishing his homework, the Azerbaijani sharpened his weapon, smoked a few cigarettes and waited in the hallway until 5 a.m., when his victim would be in his deepest sleep, according to his own court testimony.

Safarov opened the unlocked door to Lt. Markarian's room. He turned on the light. The ax blows came raining down, 26 in all, on head, neck and body — as Safarov flung insults at his victim.

When it was over, Safarov told Markarian's Hungarian roommate that he wouldn't hurt him. He smoked a cigarette and threw the butt at the victim, before calling a fellow Azerbaijani officer and showing him the body.

Then he left to hunt down a second Armenian officer in his room.

Finding the door locked, Safarov started screaming: "Open up Armenian, open up, we're going to cut the throats of all of you" — and started breaking down the door with his ax.

Hayk Makuchyan, the intended victim, told The Associated Press that he wanted to open the door to see what was going on, but was stopped by his roommate.

Police arrived and drew their weapons on Safarov, forcing him to lay down his ax.

Safarov was given a life sentence by a Hungarian court in 2006. At trial, the Azerbaijani officer said he committed the murder to avenge the killing of his relatives by ethnic Armenian forces during the 1990s conflict over the disputed territory of Nagorno-Karabakh.

He also said the Armenian officers subjected him to ridicule, throwing a basketball at him, teasing him over his studious habits and insulting the Azeri flag. Those claims weren't proven in court and ultimately rejected by the judge.

His lawyer said Safarov felt he was doing his duty. "He believed that he was defending his country," said Hungarian defense lawyer Gyorgy Magyar.

On Aug. 31, Hungary sent Safarov back home after receiving assurances that he would continue serving his sentence there.

Instead, Safarov was covered in glory. President Ilham Aliev granted him an amnesty upon his arrival. He was promoted to the rank of major, provided with a new apartment and given back wages for his eight-and-a-half years in custody.

Armenia exploded in anger.

It immediately cut diplomatic ties with Hungary as protesters in the Armenian capital threw tomatoes at the building housing Hungary's honorary consulate, and tore down the Hungarian flag.

A barrage of blustery statements from Armenian and Azerbaijani officials raised the fears about a renewed outbreak of the six-year war, which ended in 1994.

The Nagorno-Karabakh region of Azerbaijan and some adjacent territory has been under the control of Armenian troops and local ethnic Armenian forces since the war's end; shootings and other incidents have been frequent.

Negotiators from Russia, the United States and France, under the umbrella of the Organization for Security and Cooperation in Europe, have led efforts to settle the conflict, producing little result. Worried about a resumption of hostilities, Washington, Russia and the OSCE quickly condemned Azerbaijan's move.

The oil-rich Caspian Sea nation has remained defiant.

Azerbaijani Foreign Minister Elmar Mamedyarov told U.S. Deputy Secretary of State William Burns last week that Safarov's case was a consequence of the "Armenian aggression."

"The entire Azerbaijani society believes that the Armenian officer had provoked Safarov and considers his life sentence by a Hungarian court unjust," said Vafa Guluzade, an independent political analyst based in Baku. "How can Aliev keep him in custody if society believes he's innocent?"

Some Armenian commentators warned that the tensions could spiral into armed conflict.

"It became clear to everyone how difficult it is to deal with such a partner," said Ruben Safrastian, the director of the Institute of Oriental Studies in the Armenian capital, Yerevan. "The chances for negotiating a Nagorno-Karabakh peace deal have grown smaller, and the threat of war has increased."

Azerbaijan's military, which was routed by the Armenian forces during the war, has undergone a costly buildup thanks to a flow of petrodollars. The country's defense spending, of about $4 billion a year, dwarfs the entire Armenian government budget.

Resource-poor Armenia has been starved by blockades by Azerbaijan and its key ally Turkey, but it hosts a major Russian military base and is a member of a Russia-led security pact. Armenia also has a Soviet-built nuclear power plant located near Yerevan, creating potential radiation risks in case of war.

If fighting erupts, Moscow will be obliged to help its ally, raising the prospect of a major conflict in the region crisscrossed by strategic oil pipelines carrying Azerbaijan's crude to Western markets. NATO member Turkey, in its turn, has a similar obligation to Azerbaijan under a 2010 bilateral security pact.

Orujov, an Azerbaijani political analyst, said that in the current situation even a minor skirmish may trigger a full-scale conflict.

"Amid this new twist of tensions," he said, "the absence of contacts between the two countries may push them to the frontline."


Gorondi reported from Budapest; Aida Sultanova in Baku, Azerbaijan and Avet Demourian in Yerevan, Armenia contributed to this report.