The Mexican underdog knocked the Brit down four times, forcing a seventh-round stoppage. But it is Joshua who will earn the lions’ share of the fight purse.
The dethroned WBA, WBO and IBF champion will accrue £20m after suffering the first defeat of his career.
Joshua struggled to gain a foothold in the early rounds, but found a breakthrough in the third, flooring Ruiz Jr with a left hook.
The challenger recovered and showed slick hand speed to knock Joshua down twice before the end of the round with chopping right hooks to the temple.
The 29-year-old staggered back to his stool and regained composure in the following rounds, but was knocked down twice more in the seventh, leaving referee Mike Griffin with no choice but to stop the fight.
The Mexican accepted the £5m offer before the bout, over five times more than the £770,000 he received after the loss to Joseph Parker in 2017.
The most Ruiz Jr has earned for a win was a reported £382,000 against Devin Vargas in 2018.
Joshua described the loss as merely a ‘minor setback,’ with promoter Eddie Hearn expecting to arrange a rematch for December.