By David Dolan

PRETORIA (Reuters) - South African Olympic and Paralympic sprinter Oscar Pistorius sobbed in the witness stand on Tuesday as he described how, gripped by fear, he shot dead his girlfriend through a locked toilet door thinking she was an intruder.

Taking the witness stand, the double amputee - accused of murdering 29-year-old law graduate and model Reeva Steenkamp - recounted hearing a window sliding open in his bathroom in the middle of the night on Valentine's Day 2013.

Conditioned by years of living in crime-ridden South Africa, Pistorius said the noises convinced him someone was breaking into his luxury Pretoria home and that he needed to protect himself and his lover.

"That's the moment that everything changed," he said, his voice tense with emotion. "I thought that there was a burglar that was gaining entry to my home."

"The first thing that ran through my mind was that I needed to arm myself, that I needed to protect Reeva and that I needed to get my gun," said the 27-year-old, who faces life in prison if convicted of murder.

Pistorius said he felt in the dark with his fingers, grabbed a 9mm pistol lying under the bed, then moved on his stumps down the passageway leading from the bedroom towards the bathroom and the would-be intruder or intruders.

"I shouted for Reeva to get on the floor and for her to phone the police. I screamed at the people to get out," he said.

According to his account, as he peered round the door of the bathroom - his outstretched right hand holding the pistol, his left hand steadying himself against the wall - he noticed the bathroom window was open, confirming his worst fears.

"I wasn't sure where to point my firearm. I had it pointed at the toilet but my eyes were going between the window and the toilet. I stood there for some time. I'm not sure how long.

"I just stayed where I was and kept on screaming. Then I heard a noise from inside the toilet that I perceived to be somebody coming out of the toilet. Before I knew it, I had fired four shots at the door."

Story continues

"CRYING OUT TO THE LORD"

With his ears ringing, he continued to scream for Steenkamp to call the police, he said, until it slowly dawned on him that his girlfriend might have been the one behind the door.

"I was screaming and shouting the whole time. I don't think I have ever screamed or cried like that. I was crying out to the Lord to help me. I was crying out to Reeva," he said, choking back the tears.

He then recounted how he bashed out a panel of the wooden door with a cricket bat to reveal Steenkamp - the woman with whom he said had been planning on buying a house - slumped on the floor in a pool of blood.

"I sat over Reeva and I cried," he said, before breaking down into uncontrollable sobs, causing Judge Thokozile Masipa to adjourn the hearing for the day.

Pistorius' testimony was broadly in line with a sworn affidavit he gave at his bail hearing just over a year ago. At the time, magistrate Desmond Nair pointed to what he said were a number of "improbabilities" in the version of events.

"I have difficulty in appreciating why the accused would not seek to ascertain who exactly was in the toilet," Nair said at the time. "I also have difficulty in appreciating why the deceased would not have screamed back from the toilet."

"CAN'T YOU SLEEP, MY BABA?"

Several witnesses have testified to hearing a man's shouts coming from the house although they have also spoken of the terrified screams of a woman leading up to and during a volley of shots. Prosecutors allege that Pistorius and Steenkamp had a violent argument before he pulled a gun on her.

The trial, now in its 18th day, has gripped South Africa and millions of sports and athletics fans around the world who saw Pistorius as a symbol of triumph over physical adversity.

His disabled lower legs were amputated as a baby but he went on to achieve global fame as the "fastest man on no legs", winning numerous Paralympic gold medals and reaching the semi-finals of the 400 meters in the 2012 London Olympics against able-bodied athletes.

Earlier, defense advocate Barry Roux led Pistorius through a series of text messages between himself and Steenkamp that painted the picture of a young couple besotted with each other, nearly every message ending in 'xx' or a term of endearment.

The image was a far cry from the gun-obsessed, fast-living hothead whom prosecutors sought to portray in the first three weeks of the trial.

"I wish I could tuck you in and get you feeling better," Pistorius said in one message after Steenkamp complained of feeling under the weather. "Thank you for being the most beautiful person to me," she said in another message to him.

However, prosecutors have also used the same cache of messages retrieved from Pistorius' phone to reveal outbursts of temper and jealousy.

During his testimony, he also revealed Steenkamp's last words, spoken to him after he woke hot and uncomfortable in the early hours of February 14 before going to move some fans and close the external sliding doors of his bedroom.

"'Can't you sleep, my baba?'" he quoted her as saying from the bed beside him. "I said 'No, I can't'."

As he outlined his version of events, Steenkamp's mother June, who had sat steely faced throughout Pistorius' two days on the stand, leant forward slowly and buried her head in her hands.

(Additional reporting by Olivia Kumwenda and Joe Brock; Writing by Ed Cropley; Editing by Pascal Fletcher)