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 in Courtroom C of the Pretoria Magistrate’s Court.

The prosecution claims that 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 here. 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 he 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. He was instructed to report to a police station twice a week.

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, Detective Warrant Officer Hilton Botha, who has since been removed from the case, saying the officer made “several errors and concessions” and “blundered” in gathering evidence.

“It is his evidence that may have been tarnished by cross-examination, not the state case,” he said.

The sprinter was born without fibula bones and underwent double amputation as an infant, and now uses prosthetic legs. His lawyer, Barry Roux, said Friday that if he were prosecuting the case, the charge would be culpable homicide — a less serious charge implying either negligence or a lack of intention to kill.

With his head bowed and his jaw clenched as he entered the court Friday in advance of the bail ruling, Pistorius appeared to be struggling to hold back tears, as the prosecutor, Gerrie Nel, described Steenkamp’s plight Feb. 14.

During a morning session before the bail ruling, Nair seemed skeptical about the risk that Pistorius would flee.

“What kind of life would he lead, a person who has to use prostheses, if he has to flee” and found himself “ducking and diving every day” on artificial limbs, the magistrate asked.

“A life not in prison,” Nel replied, comparing Pistorius to the WikiLeaks founder Julian Assange, who has taken refuge in the Ecuadorean Embassy in London, despite his “famous face.”

Piling on emotional pressure Friday, Nel linked the death of Steenkamp to other violence against women in South Africa, including the case of Anene Booysen, a 17-year-old who was raped and murdered in the Cape region this month.

“The degree of violence present in this case is horrific,” Nel said.

The athlete’s longtime coach, Ampie Louw, told reporters Friday that he was considering putting the athlete back in training “to get his mind clear.”

Pistorius has canceled planned track appearances and several corporate sponsors, including Nike on Thursday, have distanced themselves from him.

“The sooner he can start working, the better,” Louw said.

In an aside to the case, the South Africa edition of Heat, a celebrity gossip magazine, on Friday published what it said was Steenkamp’s last interview, a week before her death, in which she said the couple had not been discussing their relationship in the media “because I don’t want to get it tainted.”

“I don’t want anything coming in the way of his career,” she said, according to an advance excerpt from the interview. “He’s such an amazing athlete.

“You know what they do, they make things up, ‘Reeva cheats on Oscar,’ and rubbish like that. I wouldn’t want lies about us jeopardizing it.”