This is one way to dump a friend.

An elderly Briton whose relationship with his pal went down the toilet saved his feces for several weeks in a revolting scheme in which he pumped the excrement into the man’s home, the Mirror reported.

Geoffrey Holroyd-Doveton, 75, of Rotherham, told police he thought Donald Wicks had contributed to his divorce more than two years ago and “ruined my life,” according to the news outlet.

Armed with his stinky load, Holroyd-Doveton traveled to Braintree, Essex, to carry out the vile attack on the home of Wicks and his hubby, Richard, while they were away on New Year’s Day.

“It would seem that the defendant defecated into a container and kept that for six to eight weeks,” prosecutor Lesla Small said. “He had constructed a homemade pump and used that pump through the letterbox.

“Using that pump he has pushed the excrement through the letterbox causing that to splatter over the hallway, up the stairs and onto the back wall,” she said.

Surveillance footage captured the vengeful pooper in the act outside the couple’s home, Small added.

Wicks described the incident in court as “despicable” and “disgusting.”

“It immediately caused me to feel very anxious and unable to sleep due to the stress,” he said. “I felt my personal space, our home, had been invaded.”

Holroyd-Doveton pleaded guilty at Ipswich Magistrates Court to causing more than $5,000 in damage.

His lawyer, Emily Hughes, said he felt isolated and depressed after his marriage failed and was “incredibly sorry for his actions.”

Judge Michael Cadman apparently found the defense a load of crap and slapped Holroyd-Doveton with a suspended jail sentence along with 80 hours of unpaid work.

He also imposed a restraining order that bars Holroyd-Doveton from contacting Wicks or venturing within a mile of his home.

“This is a pretty horrific offense. I think it is almost as bad as I have seen in my 30 years as a magistrate,” Cadman said.