The Olympic athlete also recalled the panic attacks he says he has suffered since he killed Reeva Steenkamp last year and described how he has nightmares that have caused him to wake up to the "smell of blood".
His voice trembling with emotion, Pistorius took the stand to say the Valentine's Day shooting of his girlfriend last year had left him sleepless, terrified and plagued by nightmares.
The South African paralympic star said he had fired four times through a toilet door at his luxury Pretoria home in the belief he was defending her from an intruder.
Ms Steenkamp, a law graduate and model, was hit by at least three rounds, one of which - to the head - killed her almost instantly, the court has heard.
"I was simply trying to protect Reeva," Pistorius told Pretoria High Court at the start of his testimony. The victim's mother, June Steenkamp, sitting stony-faced in the packed public gallery, bowed her head.
He added: "I wake up every morning and you're the first people I think of, the first people I pray for ... I was simply trying to protect Reeva. I can promise that when she went to bed that night she felt loved."
The 27-year-old Olympic and Paralympic star, who faces life in prison if convicted of murder, testified that he had been on anti-depressants and sleeping pills because of his disturbed state of mind since the shooting.
He said: "I'm scared to sleep. I have terrible nightmares about things that happened that night. I can smell blood. I wake up to being terrified."
He recounted one occasion when he woke up so scared in the middle of the night that he crawled into a cupboard before calling his sister, who came round to sit with him.
He said: "I wake up in a complete state of terror to the point that I would rather not sleep."
He added that his faith had got him through the situation.
He said: "There have been times when I've just been struggling a lot.
"My God is my God of refuge."
Earlier, during graphic forensic testimony from a defence pathologist, Pistorius was visibly ill.
The distraught, bespectacled figure was in stark contrast to the gun-obsessed, fast-living hothead whom prosecutors had described in the first 16 days of the trial.
Pistorius is also accused of firing a pistol through the sunroof of a friend's car while on a public road, and discharging a handgun under the table of a packed Johannesburg restaurant. He has denied all charges.
The sprinter's lower legs were amputated as a baby but he went on to achieve global fame as the Blade Runner.
After winning gold medals at the Beijing and London Paralympics, he reached the semi-finals of the 400 metres in the London Olympics.
In testimony, he described his difficult early years as a disabled child before his sporting prowess earned him respect at school.
He also spoke of the pressures of fame, the toll travelling to athletics meetings took on his family and personal life and of his fears of life in crime-ridden South Africa.
He said: "When we were growing up, we were exposed to crime - house break-ins, family members being assaulted and hijacked.
"Many members of my family have been victims of house break-ins and violent crime."
His defence hinges on his assertion, made under oath at his bail hearing, that he mistook Ms Steenkamp for an intruder hiding in the toilet and opened fire.
However, witnesses living close to Pistorius's home in a gated Pretoria community have testified to hearing the screams of a woman before and during a volley of shots in the early hours of February 14, 2013.