The work is the first stage in the development of an opera by the London art collector Danny Moynihan. Mr Hirst and Mr Moynihan have spent the last four days with the rats. 'From now on they will completely take the place over,' the artist says.
The rats, several of which are pregnant, are contained in a 25ft-square cage suspended above a bed of bracken.
The cage contains discarded packaging from medical goods. In the middle of the bracken is a glowing grey sphere, with a jellied, wrinkled appearance, which pulses with colour in time to a musical accompaniment.
Over the 21-day life of the sculpture, the breeding rats will convert the medical boxes into bedding. One has already made a nest in a packet of Prozac. The installation has provoked mixed reactions in Edinburgh.
'Some people come out ashen-faced,' Mr Moynihan says. 'They hear the scampering in the cage, and then the lights slowly come up and the rats loom into view. Others cannot bear the smell.'
Chris Brown, the Demarco Foundation's chief electrician, refuses to enter the room to maintain the neon lights used by the artist to illuminate the sculpture. Dalya Alberge, arts correspondent for the Times, fled from the gallery when Hirst threw a rubber glove at her and shouted 'rat'.
A spokesman for the Scottish Society for the Prevention of Cruelty to Animals has said the organisation is 'delighted' with the conditions in which the rats are being kept.
Mr Moynihan adds: 'Rats are far happier in this environment than they are being injected with cancer cells by the people who make the boxes which they are now making their beds out of.'
The pair aim to use the installation to attract investors in their opera, Agongo, scheduled for production in London next spring. One visitor has offered to adopt the rats at the end of the festival.
Mr Hirst, known for using preserved animals in his sculptures, first experimented with live rats at an exhibition in Dallas this July. Any rats used in the full version of the opera, however, are likely to be pickled. 'There would be no point in live rats since no one could see them,' he says.
Following the festival five rats will be handed over to an Edinburgh woman who has offered them a home. Persuaded to give evidence yesterday morning, Mr Hirst threatened to attend Mr Bridger's trial dressed as a sheep.