A giant panda has suffered an electric shock from a fence in its new enclosure.

Spectators were reportedly concerned after seeing Edinburgh Zoo’s male panda Yang Guang run back to his den after being zapped by the barrier.

The panda and his female companion Tian Tian – the only giant pandas in the UK – were moved to new living quarters earlier this month from their previous glass-walled enclosure.

They were relocated to ensure they are not disturbed by noise or vibrations from building work to redevelop a nearby former hospital.

One zoo visitor told The Scotsman newspaper: “I saw the male panda try and climb the fence and he got electrocuted.

“You could tell he was scared because he ran off into his den.

“The old enclosure had glass but this one doesn’t – it must be to stop him from climbing out, but it’s cruel.”

Zookeepers stress the electric fence is there for the safety of both the animals and the public.

Charlotte Macdonald, the Royal Zoological Society of Scotland’s director of conservation and living collections, said: “Yang Guang had one shock from an electric fence when he was exploring outside last week.

“Just like farm animals, zoo animals tend to learn very quickly to avoid electric fences, which are there for their safety and to protect the public.

“Yang Guang is being slowly introduced to his new surroundings and has been really enjoying playing on his platforms and climbing trees.”

In April, Tian Tian was artificially inseminated during her annual health check in a new attempt to produce a cub.

Last year Yang Guang, had surgery to remove both testicles after a tumour was discovered.

Panda specialists said at the time this was not a factor in the pair not having had a cub since they arrived at the zoo on a 10-year loan from China in 2011.