The little girl gave evidence in a room, separate from the courtroom, via CCTV in the case against Nicholas Ninow on Wednesday morning.
The NPA says the court had to hear from the child, as the sequence of events needed to be established.
NPA spokesperson Phindi Louw Mjonondwane said the child's testimony was moving.
“The bravery - we just could not comprehend how the child got it to come to court, tell the sequence of events. Today it was not about her telling the court about the initial or the main event of rape, because that was not in dispute, but rather it was about the sequence of events... what happened before the main event of rape.”
Mjonondwane said the child told the court that Ninow followed her to the bathroom.
This contradicted Ninow's statement in his plea explanation where he said the child found him in the bathroom.
On Monday, Ninow pleaded guilty to two counts of rape and possession of drugs.
Ninow is on trial for raping the child in the toilets at the Dros Restaurant in Silverton, Pretoria.
The state will be arguing for life imprisonment. Closing arguments will be heard on Thursday.