Mohammed Zubair, 36, attacked "defenceless" Ahmedin Khyel and Imran Khan and left his home spattered with blood, Bradford Crown Court heard.
The taxi driver, who denies two counts of murder, then drove to a secluded country lane and "dumped" the bodies, the jury was told.
Both victims had fractured skulls.
Live updates on more stories from Yorkshire
Tahir Khan QC, for the prosecution, said Mr Zubair found his wife, Kainaat Bibi, had been having an affair with Mr Khyel, 35, who lived in London with his wife and children.
Mrs Bibi had visited Mr Khyel during a temporary separation from her husband and he would visit her in Bradford where the pair would have sex when Mr Zubair was out.
On 10 May 2011, Mr Khyel visited Mr Zubair's home on Heath Terrace, Bradford, with his friend Mr Khan, 27.
The men took their shoes off thinking they would receive a "warm welcome" but the attack that followed was "ferocious" and "brutal", said the prosecution.
Mr Khan suggested Mr Zubair had "became enraged" when he saw the man who had had sex with his wife standing in his living room.
"What followed then must have been an attack with a weapon or weapons on two defenceless, unarmed men."
"Imran may just have been in the wrong place at the wrong time," added Mr Khan.
Although the room had been cleaned, blood stains matching the DNA of both men were found on the floors and walls and also in Mr Zubair's taxi, the jury heard.
The court heard two drivers saw Mr Zubair's taxi shortly before the men's bodies were found and a double murder investigation was launched.
Mr Zubair flew to Pakistan the following day on tickets booked and paid for by his mother, the court heard.
The trial continues.
A man beat his wife's lover and another man to death in a "ferocious" attack before fleeing to Pakistan, a court has heard.