The 'Clash on the Dunes' in Diriyah was for the IBF, WBA, WBO and IBO titles.
The judges scored the fight 118-110, 118-110 and 119-109 to Joshua after 12 scheduled rounds.
"It was his night, man," said Ruiz as his six-month reign ended in the 15,000 seat arena on the outskirts of the capital Riyadh.
The decision to take the fight to Saudi Arabia had been criticised by human rights campaigners but Joshua complimented the hosts and welcomed Ruiz's suggestion that there should be a third encounter.