South African athlete Oscar Pistorius said he was "deeply in love" with his girlfriend Reeva Steenkamp and had no intention to kill her.
In an affidavit presented by his defence lawyer Barry Roux at his bail hearing, Mr Pistorius said he had received death threats and kept a 9mm pistol under his bed.
The Olympic and Paralympic sprinter said: "I was absolutely mortified by the events and the devastating loss of my beloved Reeva."
In the affadavit, he said he and Ms Steenkamp went to sleep on Wednesday night sometime after 10pm.
However, in the middle of the night, he awoke in pitch darkness and thought an intruder had climbed through a window and entered the toilet.
Without putting on his prosthetic legs - contrary to the prosecution's version of events - he moved on his stumps into the bathroom adjoining his bedroom and noticed the closed toilet door.
He did not realise Ms Steenkamp was behind it, he said.
He shouted for the intruder to get out of his house then fired several shots into the door, before calling to her to phone the police.
When she did not respond, he grabbed a cricket bat to beat down the bathroom door and found her slumped on the floor, he said.
As Mr Roux read the statement, Mr Pistorius sobbed unrestrainedly, prompting magistrate Desmond Nair to halt proceedings for several minutes.
"You need to concentrate on what's going on," Mr Nair told him.
The hearing has been adjourned until 7am tomorrow.
Earlier, prosecutor Gerrie Nel said Ms Steenkamp arrived at the house between 5pm and 6pm the night before she was killed and was locked inside the bathroom, unarmed, when the shooting occurred.
Prosecutors also said Mr Pistorius told his sister that he had mistaken Ms Steenkamp for an intruder.
Mr Pistorius was arrested after Ms Steenkamp was found shot dead in his Pretoria home in the early hours of Thursday.
Police said a 9mm pistol was recovered at the house, where there was no sign of a break-in.
Mr Pistorius' agent said the athlete, who faces life in prison if found guilty, disputes the murder charge "in the strongest possible terms".
At his first bail hearing on Friday, Mr Pistorius broke down in tears when the charges were read and prosecutors said they believed the killing was premeditated.
His family said in a statement at the weekend that he was "numb" with shock and grief.
Born without a fibula in either leg, Mr Pistorius runs on carbon fibre prosthetic blades after he underwent a double amputation as an 11-month-old baby.
He was the first double amputee to run in the Olympics and reached the 400 metres semi-finals in London 2012.
Elsewhere, Ms Steenkamp has been cremated in a private ceremony in the coastal city of Port Elizabeth.
The funeral of the 30-year-old law school graduate was attended by over 100 relatives and friends.
Her uncle, Mike Steenkamp, told reporters through tears after the funeral that his niece wanted to be an activist for ending abuse against women.
He said: "Unfortunately it has swung right around, but I think that the Lord knows that her statement is more powerful now."
Ms Steenkamp's brother Adam told reporters: "There's a space missing inside all the people that she knew that can't be filled again.
"We are going to keep all the positive things that we remember and know about my sister. We will miss her."