Valuev won 116-113 and 116-114 on two judges' cards, with a third judge scoring the fight 114-114.
"Boxing is the only sport where you can get robbed without a gun," Ruiz said. "My promoter Don King should do his job and get a rematch."
Ruiz manager Norman Stone had to be restrained in the ring when the announcement was made, and German promoter Wilfried Sauerland accused him of inciting the crowd, leading to the booing.
Stone, outraged by the decision, grabbed the belt and screamed at Valuev's camp: 'You suck' as he was led from the ring by security staff.
Each side admitted the fight was close after Valuev loosened up and won the middle rounds. He became the first Russian heavyweight champion.
"I'm always fighting a smaller man and the crowd always supports the smaller man," the 32-year-old Valuev said of the crowd's jeers. "But I was perfectly sure at the end I had won.
"I had to wait 12 years for this and now it has happened. It's fantastic."
Ruiz, who weighed 39 kilograms less than Valuev 147 kilograms and was 10 inches shorter than the 2.13-meter Russian, appeared to have the fight in hand, using a jab-and-grab tactic to slip in a few punches and then tie up Valuev.
Valuev began throwing combinations in the seventh round, adding to a left jab that landed from the opening round. In the ninth, Valuev even danced a bit.
Valuev landed the only punch that did damage in the final round, hitting Ruiz on the chin with a straight left that wobbled the champion. Ruiz clinched his way to the end of the fight.
Ruiz's record fell to 42-6-1, while Valuev improved to 43-0 with one no-decision.
The American used the clinching moves that carried him through 11 title fights, with wins against Evander Holyfield and Andrew Golota.
"We knew beforehand you can't have a beautiful fight against John Ruiz," Valuev's trainer Uli Wegner said. "But my fighter jabbed him the whole fight and later he used his physical advantage. It was close, but he deserved the verdict."
This was the latest setback for Ruiz after losses to two former middleweights. He was beaten by Roy Jones Jr. and James Toney in April, but was given the title when Toney was stripped of the crown for testing positive for steroids.
At the news conference after the bout, Stone accusing the Germans of manipulating the fight, although they did not choose the judges from New Zealand, Australia and Mexico.
Ruiz's camp said they will petition for the rematch with the WBA, which they did successfully for a Holyfield fight.