"In several locations around the globe, communities are already converting things like cow dung, human waste and kitchen garbage into usable energy," writes Jennifer Horton at HowStuffWorks.com. "If you don't focus on the stuff that goes into it, biogas digestion is actually pretty neat. It works by capturing the methane gas that gets released when waste breaks down. Usually, sewage treatment plants just vent that gas into the air, but if methane gas gets captured, it can be used for things like cooking and generating electricity." And the idea is catching on, worldwide.
According to the Beginner's Guide to Biogas, this concept can "provide a clean, easily controlled source of renewable energy from organic waste materials for a small labor input, replacing firewood or fossil fuels (which are becoming more expensive as supply falls behind demand). During the conversion process pathogen levels are reduced and plant nutrients made more readily available, so better crops can be grown while existing resources are conserved."
Here's a rough idea of how it happens: