Image copyright Reuters Image caption Security was tightened around the jail where Junaid Hafeez, not pictured, was being sentenced

A university lecturer in Pakistan has been sentenced to death for blasphemy.

Junaid Hafeez, 33, was arrested in March 2013 and accused of posting derogatory comments about the Prophet Muhammad on social media.

Allegations of blasphemy are taken very seriously in Pakistan, and even an accusation is often enough to make someone a target for hardliners.

Mr Hafeez's first lawyer, Rashid Rehman, was shot dead in 2014 after agreeing to take on the case.

The lecturer has also spent years in solitary confinement, after repeated attacks by other prisoners.

The sentence was delivered by a court in the Central Jail in Multan, where Mr Hafeez was being held.

Mr Hafeez had studied a Master's degree in the US on a Fulbright Scholarship, specialising in American literature, photography and theatre.

After returning to Pakistan he took up a lecturer position at Bahauddin Zakariya University (BZU) in Multan, where he worked until his arrest.

Image copyright EPA Image caption Prosecution lawyers passed out sweets in celebration after the verdict was read out

Mr Hafeez's current counsel said the verdict was "most unfortunate", and told AFP news agency that they would appeal against the decision.

Prosecution lawyers, meanwhile, distributed sweets to their colleagues, who chanted "Allahu akbar" and "death to blasphemers".

Amnesty International said the verdict was "a gross miscarriage of justice" and described it as "extremely disappointing and surprising".

What are Pakistan's blasphemy laws?

Pakistan's blasphemy laws carry strict sentences, including death, for anyone who insults Islam.

The offences relating to religion were first codified by India's British rulers in 1860, and were expanded in 1927. Pakistan inherited these laws when it came into existence after the partition of India in 1947.

These early laws made it a crime to disturb a religious assembly, trespass on burial grounds, insult religious beliefs or to intentionally destroy or defile a place or an object of worship.

Under these laws, the maximum punishment ranged from one to 10 years in jail.

But between 1980 and 1986, a number of clauses were added by the military government of General Zia-ul Haq.

Media playback is unsupported on your device Media caption Asia Bibi's escape from Pakistan death row

Gen Haq wanted to "Islamicise" them and also legally to separate the Ahmadi community, declared non-Muslim in 1973, from the main body of Pakistan's overwhelmingly Muslim population.

The new clauses made it illegal to make derogatory remarks against Islamic personages, introduced life sentences for "wilful" desecration of the Koran, and later, introduced the death penalty or life imprisonment for blasphemy against the Prophet Muhammad.

About 40 people are currently on death row for blasphemy - although so far, no executions for blasphemy have been carried out.

The blasphemy laws have been under the spotlight internationally after Asia Bibi, a Pakistani Christian who spent eight years on death row, was freed from prison last year, following a Supreme Court decision which overturned her conviction.

Her release sparked riots, and she had to seek safety in another country.