LONDON, England (CNN) -- Britain has granted asylum to Mehdi Kazemi, a gay Iranian student who faced deportation from the United Kingdom and feared execution in Iran for being homosexual, officials confirmed Tuesday.

Mehdi Kazemi feared persecution if he had to return to Iran.

"We keep cases under review where circumstances have changed, and it has been decided that Mr. Kazemi should be granted leave to remain in the UK based on the particular facts of this case," Britain's Home Office said in a written statement quoting an unnamed UK Border Agency spokesman.

Kazemi's uncle, known as Saeed, says his teenage nephew received an "unconditional" letter of asylum from the Home Office on Monday.

Kazemi, 19, moved to London to study English in 2004 but later discovered that his boyfriend had been arrested by Iranian police, charged with sodomy and hanged.

Fearing the same fate, he applied for asylum in Britain but was denied in 2007.

The office of Simon Hughes, the member of parliament who took up Kazemi's cause, said the Home Office has granted Kazemi leave for five years.

"Like Mehdi and his family in Britain, I am delighted by the Home Office decision that my constituent, Mehdi Kazemi, can now stay in this country and will not be sent back to Iran," Hughes said in a written statement.

"As I have argued over the last 18 months, the Home Office should not send gay and lesbian people back to countries where they will be at risk of persecution, torture or worse," he said.

Hughes was expected to meet with Kazemi late Tuesday.

Peter Tatchell, of the London-based gay rights activist group OutRage, said the decision "is a victory of sorts in that Mehdi has gotten only a temporary leave to remain. At the end of five years, he will have to go through the whole appeal process again."

He added, "Mehdi wouldn't have got leave to remain if there hadn't been massive publicity to his case. There are many other gay and lesbian Iranian asylum-seekers that are scheduled for deportation to Iran."

All About Iran • United Kingdom • Human Rights Policy