If Azerbaijan expected gratitude for releasing a blogger from prison early, it has miscalculated.

When Russian-Israeli travel blogger Alexander Lapshin was released after seven months in an Azerbaijani prison, his lawyer announced that Lapshin had written a letter of thanks to the country's president, Ilham Aliyev.

"Today I learned that you [Mr. President] have signed an order on my pardon. I am very thankful to you for this," said the letter, released on September 13 by Lapshin's lawyer in Azerbaijan.

Lapshin had been arrested in Belarus in December, and then extradited to Azerbaijan in February, for crossing into Nagorno Karabakh, the territory that is internationally recognized as part of Azerbaijan but which is controlled by Armenian forces.

His time in prison, it appeared, had changed his views on the Karabakh question. "Now I am fully convinced that Nagorno-Karabakh is Azerbaijani territory. I hope that the Nagorno-Karabakh problem will be resolved within Azerbaijan’s territorial integrity,” the letter continued. The blogger "also wished President Ilham Aliyev strong health and long life, expressing hope for the soonest liberation of the Azerbaijani territories," news agency APA reported.

To no one's surprise, however, as soon as Lapshin was out of the country his views quickly shifted. He took to his blog and Facebook to tell his side of the story, which contradicted the Azerbaijani narrative in almost every respect.

For one, he denied Azerbaijani government statements that he had attempted suicide while in prison. Instead, he wrote, he was badly beaten, to the point that he passed out and woke up in a hospital hooked up to a catheter and an oxygen mask. He further speculates that the attack was carried out to discredit Aliyev personally, which he says corresponds to what he has been told by Azerbaijan's opposition living abroad.

He also thanked a number of people who helped him while he was in prison, none of whom was Aliyev. Instead, he expressed gratitude to the staff of the Russian and Israeli consulates in Baku, who visited him regularly. And he thanked the Red Cross, which he lauded not just for helping him but for its work "in such troubled countries as Azerbaijan, Somalia, Afghanistan, and Rwanda."

He even more strongly took back his statements about Karabakh, declaring in a Facebook post that it was without doubt Armenian territory.

“I am ashamed of admitting that before I found myself in an Azeri prison I sincerely believed that the Karabakh conflict is a very disputed one and should be resolved on the basis of respect for Azerbaijan’s borders,” he wrote. “What an idiot I was! Already in 1988 Azerbaijan began terror against Armenians in Sumgait, Baku and Karabakh.”

“Armenians, hold firm!” he concluded. “These people want to see you dead, full stop. And if you lose Karabakh as a result of negotiations or a weakening of Armenia’s position, be aware that they will come to slaughter you. Just like the Turks did 100 years ago. Their brutality already has exceeded all acceptable limits."

The post set off the mother of all social media fights between Armenians and Azerbaijanis; 20 hours after it was posted it had already gotten more than 2,900 reactions (either likes or hates), over 1,000 shares and hundreds of comments.

It's unclear how Lapshin, if he went into prison in Azerbaijan believing that the Karabakh question was "disputed," how he left it seemingly having absorbed a strongly Armenian nationalist view of the history and conflict.

What's very clear, though, is that Azerbaijan has created for itself a PR disaster entirely of its own making, and that shows no signs of going away soon. In the space of about 24 hours he's already written three blog posts and has a knack for hitting all of Azerbaijan's sore spots, claiming the country is a hotbed of Islamist extremism and anti-Semitism, on top of everything else. He's started the hashtag #azeromarazm, translating roughly to "Azeri stupidity," which a number of Armenian twitter users have adopted gleefully.

Ironically, give the anti-Semitism claims, the timing of Lapshin's release appears to be connected to a visit by Defense Minister Zakir Hasanov to Israel. Baku appeared to think the pardon would be a humane gesture to show their Israeli partners, which now seems to have badly backfired.