The prosecution had asked for the evaluation after a psychiatrist told the court on Monday Pistorius, who is on trial for the murder of Reeva Steenkamp, suffered from an anxiety disorder.
Prosecutor Gerrie Nel has argued he wanted to prevent the 27-year-old sprinter, who faces life in prison if convicted, from later appealing on the basis of a disturbed mental condition.
Defence lawyer Barry Roux had argued against the motion, saying it was premature to have the evaluation before he called other witnesses.
But Judge Thokozile Masipa ruled a mental assessment would ensure Pistorius gets a fair trial, adding she thought it "strange" the defence had opposed the motion.
Ms Masipa said the court would hand down the details of how the assessment would be carried out on Tuesday. It would be preferable for Pistorius to undergo the evaluation as an outpatient, she said.
Pistorius, who has frequently vomited into a bucket and broken down sobbing during the trial, showed no emotion as he stood in the dock listening to Ms Masipa's ruling.
His uncle Arnold Pistorius said: "As a family we are comforted by the thoroughness and detail of this judgement."
The evaluation is expected to take around 30 days and will prolong the trial which began on March 3.
The court will likely use the evaluation to determine whether Pistorius lacked "criminal capacity" at the time of the shooting due to his mental disorder, South African legal expert John Welch said.
In that case, Pistorius could be sent to a mental institution for the rest of his life. If Pistorius is judged to have a "diminished criminal capacity" the trial would continue, although the track star could receive a lesser sentence if convicted.