A Perth man who fatally stabbed his one-time love rival claims he acted in self-defence because the victim had a "longstanding and visceral" hatred of him that had provoked repeated attacks.

Key points: Daniel Carrington and Ben Egan had a violent history culminating in a fatal attack

Daniel Carrington and Ben Egan had a violent history culminating in a fatal attack Their relationship was "strained" stemming from an affair involving Mr Egan's partner

Their relationship was "strained" stemming from an affair involving Mr Egan's partner Mr Carrington's lawyer said he felt like a "sitting duck" when confronted by Mr Egan

Daniel Carrington is on trial in the Supreme Court accused of murdering 38-year-old Ben Egan at a Northbridge apartment complex in April 2017.

Prosecutors allege Mr Carrington "ambushed" Mr Egan as he entered the Newcastle Street complex, stabbing him seven times and leaving him with several chest wounds before running away.

State Prosecutor Michael Cvetkoski said the two men were known to one another and had been friends, but around the time of the alleged murder their relationship was "strained".

He said that was due to a number of factors, including that Mr Carrington had a brief sexual relationship with Mr Egan's partner — the mother of his four children.

Forensic police examine the crime scene at an apartment complex in Northbridge. ( ABC News )

Mr Cvetkoski said Mr Carrington also believed Mr Egan had stolen some of his property and owed him money for drugs, alleging that he declared to someone in the days before the incident that he "was going to stab the deceased man".

In an opening statement, Mr Carrington's lawyer, Jonathan Davies, told the jury he would argue that his client should be acquitted because there was more to the case than what had been alleged by the prosecution.

Violent history between two men

Mr Davies said Mr Egan's life had been taken over by methylamphetamine addiction, which he claimed had made him "violent and unpredictable".

He held "a longstanding and visceral hatred" for Mr Carrington, mainly arising out of jealousy over the relationship with Mr Egan's partner.

He told the court in the years before the stabbing, Mr Egan had threatened to stab and kill his client, whom he had previously attacked three times, including once on a busy street when he "came out of the shadows and lunged at him" with a knife.

Ben Egan was stabbed seven times at the Northbridge apartment complex in April 2017. ( ABC News )

Mr Davies said Mr Carrington believed that Mr Egan, whom he described as "completely irrational", was out to kill him, and when he saw him arrive at the apartment complex he believed he was going to be ambushed.

"He was frozen with fear. He believed Ben Egan had come to kill him," the defence lawyer said.

"He felt like a sitting duck … his worst fears were realised so he rushed forward with a knife.

"He believed a pre-emptive strike … was his only chance of escape."

Mr Davis said Mr Carrington thought he had only used minimal force and he was surprised and devastated to learn that Mr Egan had died.

Mr Davies said he would be arguing that Mr Carrington's actions were reasonable, necessary and justified because he believed the only way he could save himself was to do what he did.