The child, who has yet to be named, was at Great Baddow high school in Chelmsford with members of his family on Thursday when the incident occurred at the schools swimming pool, the regions ambulance service said.
An air ambulance landed at the school but the boy was taken by land ambulance to Broomfield hospital in Chelmsford where medical staff were unable to save his life, the East of England ambulance service said.
Boy, 9, dies after locker falls on him at after-school swimming club
An Essex police spokesman said officers were called by the ambulance service at about 6.15pm to the school in Duffield Road.
The nine-year-old boy was believed to have fallen from a locker and become trapped underneath it, he said. He was taken to hospital, where he sadly died.
The child was not a pupil at the school and had been there with family members at an after-school club.
A statement on the schools website said it was closed on Friday due to exceptional circumstances except for year 11 and year 13 students sitting exams.
The specialist science and sports college is described on its website as a happy, safe and successful 11-18 school.
The schools headteacher, Carrie Lynch, said: The thoughts and prayers of everyone at Great Baddow high school are with the family and friends of the child who died yesterday evening, his school and swimming club.
Vicky Ford, the Conservative MP for Chelmsford, tweeted that she was very sorry to hear the terribly sad news of a death of a young boy at Great Baddow School. My heart goes out to his family, friends, teachers and all the school staff.
The boy was attending an after-school club at Great Baddow High School in Chelmsford, Essex, with family members