Johnny Depp branded his ex-wife "Amber Turd" and joked she was "in the dumps" after he found a poo in his bed.
The Hollywood actor, 57, spend four days this week giving evidence at London's High Court as part of his libel case against News Group Newspapers.
In his witness statement, Depp claimed he decided to end their marriage in 2016 when a poo was left in their marital bed, which he believes was left by Amber or one of her friends.
During his testimony yesterday, the court heard Depp had been sent a picture of the poo by his assistant and replied with a series of jokes - calling his wife "Amber Turd”' and adding "Amber’s in the dumps".
In one message, read out in court, Depp wrote: “It’s hilarious. Not sure I’ve laughed this hard for years. At least the photographs are good."
He later insisted the poo incident forced him to make "the difficult decision not to see [Heard[ anymore", calling it a "fitting end" to their marriage.
During the alleged incident May 23 2016, Depp accused Amber's friend IO Tillett Wright of being responsible for the poo.
Amber called Wright up so he could defend himself and Depp snatched the phone, the court heard.
The previous month Depp and Heard had a fight after he showed up late to her birthday party and left early.
Sasha Wass QC, The Sun's lawyer, said Depp threw a magnum of champagne at Heard before dragging her to the floor by her hair, which he denies.
The next day Depp received a call from his housekeeper to say she had found faeces in the bed.
Heard denied it was her and said it must been one of their two dogs, but Depp said it was too large to "come from a three or four-pound dog".
Ms Wass said he had accused iO Tillet, who was "part of the conspiracy" to make allegations of domestic violence against Mr Depp, of defecating in the bed.
The actor said: "iO Tillet Wright seemed the only one that would be crass enough to commit such an act."
Depp claims Amber confessed to their estate manager it had been a "harmless prank", suggesting that she was responsible.
He also said the prank made up his mind to end the marriage but the former couple continued to text each other.
Sasha Wass asked if the first topic of conversation between himself and Amber Heard during his visit to the apartment was the "defecation incident" and suggested he brought it up to provoke a row.
Depp said he was at the apartment for no more than half an hour and that it was Ms Heard who brought up the earlier incident, following which he had suggested calling his estate manager Kevin Murphy.
He said: "We had conversations... Ms Heard was very upset and she was looking forward to clearing that matter up by saying that it was the dog who had done it, which is physically impossible.
"That is why I suggested we call Mr Murphy. But in the context of what I was going through, this is a day and a half or two after my mother had passed away, I can promise you that I was not going into Ms Heard's space looking for an argument."
The actor denied a number of assertions put to him by Ms Wass, including that he was under the influence of drink and drugs when he arrived at about 7pm, and that he immediately brought up the defecation incident as he was "spoiling for a fight".
He replied: "No ma'am. Ms Heard brought up the subject of the defecation on the bed."
Sasha Wass said Heard was on the phone to IO Tillett Wright , who was laughing at Depp's suggestion that he was the friend of Ms Heard who was responsible for defecating in the bed.
She said the actor picked the phone up at one stage and told Mr Tillett Wright he had "got what you want, you can have her, I don't care, it's over".
The trial continues.