A teenage boy has been hanged in Iran after allegedly raping another boy.

Hassan Afshar, 19, was executed at the prison in the city of Arak on July 18, according to Amnesty International.

The secondary school pupil was executed after he was convicted of raping another boy, during a two-month trial in which he had no legal representation.

Afshar was arrested in 2014 along with two other youths, after they were accused of forcing a teenage boy to have sex with them by his father.

However, Afshar maintained that the sexual acts were consensual and that the alleged victim had willingly engaged in same-sex sexual activities on numerous previous occasions, leading LGBT activists to claim the teen was executed simply for being gay.

‘Homosexual conduct’ remains illegal under Iran’s Sharia law and is punishable by fines, public flogging or even execution.

Afshar was informed of his death penalty verdict seven months after he was convicted and was executed behind closed doors without the knowledge of his family.

The execution went ahead even though he was only 17 at the time of the alleged crime, with judicial officials promising to review his case in September.

His death marks the country’s first confirmed execution of a juvenile this year, with 160 other young offenders on death row.

Iran executed at least 75 juvenile offenders between 2005 and 2015 – including 13 last year – according to Amnesty.

Shockingly, Iran remains a signatory to the UN Convention on the Rights of the Child – which prohibits the use of the death penalty for children.

“Iran has proved that its sickening enthusiasm for putting juveniles to death, in contravention of international law, knows no bounds,” Magdalena Mughrabi – an interim deputy director at Amnesty – said.

“They could not execute him quick enough.”

At least 259 people have been executed this year so far, following a total of 977 last year – the highest death toll since 1989.

Earlier this year, a Muslim cleric told how he was forced to flee the country after he was attacked for marrying gay couples.