Warrant officer Hilton Botha, a detective with 24 years on the force, also told the Pretoria magistrates court that police had found two containers of testosterone and needles in Pistorius' bedroom.
Pistorius, a double amputee known as the "Blade Runner" because of his high-technology carbon fibre blades, broke down in tears as Botha presented his testimony about the death of law graduate and model Reeva Steenkamp, 29.
The shooting and allegations that have emerged at the bail hearing have stunned South Africa and the millions around the world who saw the track glory of the athlete, who has no lower legs, as an inspiring tale of triumph over adversity.
In an affidavit delivered on Tuesday, Pistorius said he slept with a 9-mm pistol under his bed and had grabbed it when he awoke in the middle of the night thinking an intruder had climbed through his bathroom window and entered the adjoining toilet.
The 26-year-old - the most successful athlete in the history of the Paralympics - then described how he fired into the toilet door in a blind panic, in the belief the intruder was lurking in the toilet.
In his testimony, Botha disputed Pistorius' affidavit.
"I believe he knew she was in the bathroom and he shot four shots through the door," the detective said, adding that the angle at which the rounds were fired suggested they were aimed deliberately at somebody on the toilet.
Pistorius had said he moved into the bathroom on his stumps - the reason he felt so vulnerable.
But Botha said the shots appear to have been fired in a "top to bottom" trajectory, suggesting Pistorius was wearing his artificial legs when he pulled the trigger.
Botha said a witness on the upscale gated community north of Pretoria where Pistorius lived had spoken of a domestic argument coming from the athlete's home between 2am and 3 am.
One witness then said he heard a shot, followed 17 minutes later by more shots, Botha said. Another witness spoke of a shot followed by screams, followed by more shots, he added.
Steenkamp was hit in the head, arm and hip in the locker-sized toilet room adjoining the bathroom, which itself led from the bedroom.