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.
(Vajrayana) Buddhism is an non-theistic teaching. All deities, yidams etc. are understood to be expressions of one's own nature, one's own mind. At the same time, it is clearly understood that "one's own" mind is not really "one's own" -- because there is no such independent entity as "I", the mind does not have boundaries between outer and inner. From this perspective the energies, deities and other inhabitants of the noosphere can indeed be considered "independent" agents (subject to caveat of universal Emptiness). As part of working on a tantra, practitioner interacts and communicates with the deities, participates in rituals etc. that may look like deity worship but are in fact psychoenergetic exercises. When involved in tantra though, we must clearly see that all these experiences are 100% real, otherwise they will not produce the intended effect on the mind. Because reality is an interpretation we make, being able to sincerely switch between alternative interpretations (materialistic, phenomenological, energy-centric, animalistic) is an important skill to be acquired towards complete mastery of the mind-made reality.
If you pet a cat it will like you. If you respect a king he will reward you. Similarly for Devas. Buddha mentioned Deva Bali offering to the Devas in the context of how to spend what you have earned.
The concept of Deva in Buddhism is that they are just another form of life as mentioned previously.
I agree with catpnosis that a mere belief in gods, as Buddhism understands them, does not entail anything that contradicts the law of kamma. Buddhism holds the view that there is no ruling god who is responsible for everything that happens, but also holds the view that there are great, virtuous, and powerful non-human beings who, on account of merit, have achieved great beauty, long life, and power.
That said, whether or not prayer is advised depends on what you mean by prayer. If you understand prayer to include merely the focusing of one's mind on a deity or some aspect of the deity then even Theravada Buddhism does allow and advocate it, through a practice called the recollection of the devas. One of the ten recollections, virtuous Buddhists are advised to recollect the virtues of the devas and to reflect that they have similar virtues in themselves. See the Mahanama Sutta.
Multiple gods are just living beings, and god (or deva) is type of good birth. So, believing gods is easy—it is just more fortunate world, or life form, than ours. • It does not contradict idea of karma because beings rebirth as gods because of their own wholesome deeds. • Praying to gods is not forbidden as general act, but this is not Buddhist practice. Even though this is not Buddhist practice this does not necessarily contradict the Dharma, it would hugely depend on practitioner attitude and views. But if you pray for salvation or to clean sins this would contradict with karma.
This question doesn't mention which sect.
Modern secular Buddhists are atheists and agnostics. Stephen Batchelor is probably the most famous speaker for this group.
The historical Buddha, may or may not have been a theist. He appears to have been singularly uninterested in Gods, made jokes about them, and saw the whole Hindu enterprise as a distraction from the real problems of existence. Glen Wallis's "Basic Teaching of the Buddha" makes a plausible case for this historical Buddha.
There isn't just one historical Buddha. The historical Buddha is a modern construct made up of half forgotten memories and text filtered through a lot of people. So for the Mahayana crowd, especially devotees of the Lotus Sutra, the historical Buddha was and is, a almost god like being of long life and powers we can't comprehend, who is still alive and an active force in our world.
There is also the Adibuddha and Vairocana, the primordial Buddha or the Buddha from which all other Buddha's are an emination of. This particular Buddha sounds a lot like a Judeo-Christian god.
Finally, Buddhism isn't just what the founder may have said. It's a syncretic tradition that absorbed bits of Hinuism, Bon, Chinese Ancestor worship, Japanese emperor worship, and now in the west it is absorbing new age and Christian elements. This is possible in part because the concerns of the historical Buddha were somewhat orthogonal to the concerns of a devotional religion. The eightfold path is much the same regardless to if you are also engaging in a devotional religion. This differs from say, monotheism, where there are explicit rules about participating in other religions. (Not to say that Buddhism didn't acquire similar rules-- for example Chinese Buddhist text often warn about following outer paths, i.e other religions)
Most Buddhists pray to devas, or gods. Some because of filial piety, particular devotion, family tradition, or any combination of the three (or more) reasons. People also pray to Bodhisattvas and Buddhas in a way that is pretty much indistinguishable from prayer to devas. In Chinese Buddhism, it is a pretty common practice to repent of wrongdoings with Buddhas/Bodhisattvas as witnesses of the promise to do better as well.
Devas are still subject to karma, since the heavenly realm is still within samsara. They can be benevolent, malevolent (although this would cause them to be reborn in a lower realm), or indifferent. They are still powerful, and can protect people. The typical logic is that a person has good karma if for any reason a particular deva takes a liking to them and helps them. In Siddartha's previous lives, he had such good karma that he was protected by devas.
Devotion and supplication to Buddhas and Boddhisattvas may be considered "safer" because they are more consistent with their compassion, while devas have different personalities, which can make them more or less "fickle". Even "wrathful Buddhas" are called so because they are fierce protectors of the dharma and dharmic people.
Institutional Buddhism still respects the individual native devas of particular regions. In one essay contained in the book "Living in Amida's Universal Vow", it was pointed out that some of the earliest "Code of Conduct" rules in Jodo Shinshu temples contained the rules "Do not disparage other Buddhas [besides Amida]" and "Do not disparage the kami ["devas" of Japan]". I do not have the book with me at the moment, but when I find the exact essay I will be more than happy to edit this post with the correct citation.
The GOD concept on Buddhism is a wide scale subject, and according to my understanding Buddhism explain higher spirits who are called "GOD" in English.