PRETORIA, South Africa — After four days of combative hearings, a South African magistrate Friday granted bail for Oscar Pistorius, the double-amputee track star accused of murdering his girlfriend in a case that has horrified and fascinated the nation and much of the world.

Magistrate Desmond Nair announced the decision after impassioned final arguments from the defense and the prosecution.

The prosecution claims Pistorius gunned down his girlfriend, Reeva Steenkamp, 29, a model and law-school graduate, on Feb. 14 after she locked herself in a small bathroom in his sprawling home in a gated complex. Pistorius, 26, says he mistook Steenkamp for a burglar, and expressed deep anguish at her death.

The prosecution had argued that Pistorius should not get bail because he could flee the country and had a history of violence. But Nair rejected these arguments, saying Pistorius did not represent a flight risk and was not likely to interfere with state witnesses.

“The accused has made a case to be released on bail,” he said, while the prosecution had not established a case for detaining him.

Pistorius’ family members in the packed courtroom shouted, “Yes!”

Nair set bail at 1 million rand (about $112,000), an unusually high amount for a murder trial in South Africa, and ordered a series of conditions before the case was adjourned to June 4. Pistorius was told to relinquish firearms and passports and to avoid his home, which is now declared a crime scene.

Pistorius was also told that he could not make contact with witnesses, leave the Pretoria area without official permission or use drugs or alcohol while the trial is pending.

Arnold Pistorius, an uncle who has acted as a family spokesman, told reporters: “We are relieved by the fact that Oscar got bail today, but at the same time, we are in mourning for Reeva Steenkamp and her family.”

But Kim Myers, a friend of Steenkamp, said: “I think it is important to remember that someone lost their life. We trust and hope that justice will prevail.”

Before announcing his ruling, the magistrate recounted the four days of conflicting arguments by defense and prosecution lawyers.

Nair sharply questioned Pistorius’ account of what happened the night Steenkamp died, asking why he had fired into the bathroom door without asking who was there, why he had not seen that Steenkamp was not in the bed beside him when he arose to check out a strange noise, and why he had not fled rather than confront an intruder. These questions are likely to be central to the murder trial.

However, Nair also took particular issue with the testimony and actions of the prosecution’s lead investigator, Hilton Botha, who has since been removed from the case, saying the officer made “several errors and concessions” and “blundered” in gathering evidence.