Do Buddhists believe in gods? As far as I know, many Buddhists believe in multiple gods. Doesn't this contradict the idea that the world is governed by the law of karma? Is praying to gods allowed?
Most Buddhists believe in some form of "higher" being; brahmas, devas, etc. It is not an orthodox Buddhist practice to pray to these deities, but people are people. Ordinary Buddhists from most, if not all, traditions, tend to succumb to the allure of prayer and supplication; most monasteries are now called "temples", monks are often called "priests", statues of Ganesha and other mythical gods are popular in these places. Some Sri Lankan monasteries actually have dedicated areas for deity worship.

How can they? Well, Buddhism doesn't demand complete adherence to Buddhist principles. I recently taught meditation at a Catholic college to priests and they seemed to gain benefit from it; one of them is planning on coming to do an intensive meditation course with me. So, the question of whether it is "allowed" doesn't really apply. Deity-worship is not recommended, since it promotes delusion and dependency, both of which are antithetical to Buddhism practice. Someone who clings to external support, real or imaginary, will not likely take full responsibility for their future, most likely becoming complacent and clinging to positive experiences as divine intervention (and therefore worth clinging to).

Does it contradict the theory of karma? Yes, and more importantly it goes against observations; praying to gods doesn't produce any observable change except in the mind of the believer. That in and of itself might be reason to promote prayer, since faith can have beneficial, uplifting effects on the mind, if it weren't misplaced and therefore promoting delusion and clinging as well.

So, it is allowed simply because we don't disallow things (except for monks who have strict rules - a monk who encourages theistic worship should be subject to reprimand, I think), but it is (or should be) discouraged because of its relationship to delusion and clinging.

Incidentally, to show how tolerant the Buddha was, in the Ratana Sutta he says:


  O beings, listen closely. May you all radiate loving-kindness to those human beings who, by day and night, bring offerings to you. Wherefore, protect them with diligence.
  
  http://www.accesstoinsight.org/tipitaka/kn/snp/snp.2.01.piya.html