Somer Umeed Bakhsh, 16, and his brother Areeb, 14, have lived in Glasgow since their family fled Pakistan in 2012 after their father received death threats due to his Christian faith.
More than 94,000 people signed two online petitions urging the UK Government not to deport the brothers to their birth country following a Church of Scotland campaign.
First Minister Nicola Sturgeon had previously described the brothers as a "credit to Scotland".
Somer, who this month achieved four As and a B in his Highers and aspires to be an astrophysicist, said: "We have gone through a tough time and I am really happy that we now have the freedom to stay in the country we love.
"I feel like a weight has been lifted off my shoulders because the threat of deportation was always in the back of my mind.
"Scotland is my home, I have grown up here, all my friends are here and I feel like a Scottish boy.
"I am very thankful to everyone who has supported my family and the people who signed the petitions. We could not have got to this point without you.
"But I am disappointed that we will have to apply to the Home Office for an extension in just two-and-a-half years."
"They will be really happy to hear the news and I am looking forward to a degree of normality.
"And hopefully life will be easier because we have been opened up to many more opportunities."
Mr Umeed Bakhsh, a trained data analyst, and his wife, a midwife and nurse, will soon be granted work permits and have the opportunity to drive and take their sons on holidays abroad.
The Church of Scotland said the process to secure permanent leave to remain is likely to cost the family tens of thousands of pounds.
The family are active members of Possilpark Parish Church in Glasgow.
Their minister Reverend Linda Pollock has led the campaign to stop them being deported to Pakistan, where blasphemy carries the death penalty.
She said: "I am relieved and feel deep joy that this decision has been made because these youngsters have been living in a psychological prison and in bondage for too long.
"They are brave, inspirational, compassionate, intelligent, well-rounded boys who have experienced sorrow and heartache.
"But through all of this they have maintained their dignity and integrity, which has not been easy.
"They have not allowed the barriers of the prison that they have been forced to live in to make them bitter, which is a credit to them and their parents."
A Home Office spokesman said: "The UK has a proud history of granting asylum to those who need our protection and every case is assessed on its individual merits."
Paul Sweeney MP, who raised the case in the House of Commons, said: "I'm delighted at this news and in particular I'm pleased for Somer and Areeb, who will be able to continue their education among the school friends who stood by them through this campaign."