This is described by Mozart’s father, Leopold Mozart, in a letter to his wife:
[Sent from Rome, dated April 14, 1770. Only parts of the letter relevant to the transcription episode are given here.]
We arrived here safely on the 11th at noon. I could have been more easily persuaded to return to Salzburg than to proceed to Rome, for we had to travel for five days from Florence to Rome in the most horrible rain and cold wind. I am told here that they have had constant rain for four months and indeed we had a taste of it, as we went on Wednesday and Thursday in fine weather to Saint Peter’s and to the Sistine Chapel to hear the Miserere during the mass, and on our way home were surprised by such a frightful downpour that our cloaks have never yet been so drenched as they then were…
You have often heard of the famous Miserere in Rome, which is so greatly prized that the performers in the chapel are forbidden on pain of excommunication to take away a single part of it, to copy it or to give it to anyone. But we have it already. Wolfgang has written it down and we would have sent it to Salzburg in this letter, if it were not necessary for us to be there to perform it. But the manner of performance contributes more to its effect than the composition itself. So we shall bring it home with us. Moreover, as it is one of the secrets of Rome, we do not wish to let it fall into other hands, ut non incurramus mediate vel immediate in censuram Ecclesiae.
—translation by Emily Anderson, in her The Letters of Mozart and his Family; London: Macmillan, 1938.