Police are continuing to question a teenager after a 16-year-old boy, described as a "gentle and caring pupil", died in a stabbing at an Aberdeen secondary school.

The fifth-year pupil, understood to be Bailey Gwynne, was taken to Aberdeen Royal Infirmary with serious injuries after police were called to Cults Academy in the west of the city at about 1.30pm on Wednesday. He died a short time later in hospital.

A teenager, also 16, was detained by police after the incident and is continuing to help them with their inquiries.

It is understood he was held overnight.

First Minister Nicola Sturgeon was among those who expressed their shock after Bailey Gwynne died in hospital following an alleged incident with another pupil of the same age.

Police Scotland launched a murder inquiry after what officers called a "shocking and extraordinary" incident at the school, which is consistently one of the best performing in Scotland.

It is understood the incident happened in a walkway section of the building, known to pupils as "the street". A 16-year-old man has been detained in connection with the incident.

Emergency services attended the scene at around 1.30pm and took the victim to the city's Aberdeen Royal Infirmary where he died.

Aberdeen City Council has arranged for support to be available to the school's pupils and teachers and the school will be closed for several days to allow police to continue with their investigations on site.

Anna Muirhead, headteacher at Cults Academy, paid tribute Bailey Gwynne who she described as "gentle and caring boy".

She said: "The whole school has been shocked and saddened by the death of a pupil at our school.

"He was a very gentle and caring boy, with many friends.

"Everybody in the school is devastated and our thoughts are with his friends and family at what is a very difficult time."

Ms Sturgeon was among the many to offer their condolences. She wrote on Twitter: "All my thoughts are with the family and friends of the young man who has tragically died at Cults Academy today."

Angela Constance, Education Secretary, said: "I'm deeply saddened by this terrible news and my thoughts are with the pupil's family and friends."

Rt Rev Dr Angus Morrison, Moderator of the General Assembly of the Church of Scotland, offered prayers for the young man and his family.

He said: "It is hard to take in that an incident resulting in the death of a teenager could occur during the course of a day in one of Scotland’s schools."

Rt Rev Dr Bob Gillies, Bishop of Aberdeen and Orkney, said he was "deeply saddened to hear of the fatal stabbing at Cults Academy and sends his heartfelt condolences to the bereaved family of Bailey Gwynne".

Bishop Gillies added: “Such dreadful events as this impact in the most terrible of ways upon so many people and upon so many families.

"My deepest grief is with all those whose lives have been changed for ever as a result of this death.”

Cults Academy is the largest state school in Aberdeen and also one of the best performing, consistently winning awards for its exam results.

Yesterday, mourners placed floral tributes and cards outside Cults Academy in tribute to Bailey.

Jenny Laing, Aberdeen City Council leader, said: "I am sure that I speak for everyone across the city when I say how shocking this is. I would like to offer my sincere sympathy to the boy’s family and friends at this most difficult time.”

David MacPherson, a minister at the Free Church of Scotland and a father of three children who have been pupils at the school, said: "This isn't typical of Cults.

"It's quite a quiet, affluent area. I can't remember anything like this ever happening around here - let alone of this magnitude."

Chief Inspector Graeme Mackie, of Police Scotland, said it was a "shocking and extraordinary" incident.

He added: "Firstly our thoughts are with the family and friends of the boy who has sadly lost his life today.

"A full and thorough inquiry is under way has been launched and there will be a police presence in the area for the foreseeable future.

"We are working closely with the education authorities and wider community as I am sure this incident will be felt not only in Aberdeen but much further afield."

It is the latest in a series of knife incidents involving young people.

Scotland's top prosecutor was prompted to move against the scourge of knife crime at schools in Scotland after meeting one victim's family.

School friends of Inverclyde Academy pupil Christopher Knox, who was stabbed when he was 17 in his home town of Greenock in June 2011, campaigned over the dangers of carrying a knife and created a DVD warning of the risks.

Campaigns like No Knives Better Lives are credited for helping push down number of people carrying blades but the Lord Advocate has said "more needs to be done".

In Glasgow in March, a 14-year-old schoolboy was treated in hospital after a suspected stabbing at one of Scotland's largest schools. Police launched an investigation after being called to Holyrood Secondary School in the south side of the city.

In October 2014, a 15-year-old pupil was treated for knife wounds after allegedly being stabbed by a fellow pupil in a lane yards from his school in Wishaw, Lanarkshire.

In Glasgow in 2000, 15-year-old Neil McMartin suffered stab wounds after four intruders attacked him outside a maths class at Mearns Castle High in Newton Mearns, Glasgow.

In April 1991, 16-year-old Diane Watson was stabbed to death by a fellow pupil, Barbara Glover, during the morning break at Whitehill Secondary School in Glasgow. Glover was convicted of murder.

Aberdeen City Council has set up a dedicated support number - 01224 264299 - for those affected by the incident to call.