In most cases, they are angels that rebelled against God, led by Lucifer (as some mangas tell me @.@ ). They were struck down into Hell, at which point they fell from grace and gradually transformed into demons.
Now, as for the japanese Oni and youkai, it's quite a bit different. Here's what Wiki says about the origins of Oni :
"The word "oni" is sometimes speculated to be derived from on, the on'yomi reading of a character (隠) meaning to hide or conceal, as oni were originally invisible spirits or gods which caused disasters, disease, and other unpleasant things. These nebulous beings could also take on a variety of forms to deceive (and often devour) humans. [...]
The invisible oni eventually became anthropomorphized and took on its modern, ogre-like form, partly via syncretism with creatures imported by Buddhism, such as the Indian rakshasa and yaksha, the hungry ghosts called gaki, and the devilish underlings of Enma-Ō [aka Yama from DBZ] who punish sinners in Jigoku (Hell)."