Toss the perpetrator
The first step to getting rid of a bad smell in your fridge is to find out what's causing it and throw it out. Chances are it's just one item, like some lettuce rotting in the crisper or particularly pungent leftovers. Of course, if your fridge lost power for an extended period of time you may need to ditch everything. Use your judgment.
Even if you didn't have to purge the contents your fridge, this is as good a time as any to give it a good cleaning. Use your favorite antibacterial cleaning spray and a dishcloth or paper towels to wipe down all the surfaces.
Next, you're going to want to put something in the refrigerator that will absorb the smell. Baking soda is the classic choice, but ground coffee or even tea bags are great alternatives. Leave them in open containers in the fridge for as long as there is an odor (many people opt to leave an open box of baking soda in the refrigerator at all times as a preventative measure).
Once you have the smell mostly gone, you can start to mask it just a little with a few natural kitchen "perfumes." Rub a vanilla extract-soaked cotton ball on the shelves for a fresh vanilla scent or spread a few lemon slices throughout the shelves (just don't forget about them and let them get moldy — you'll be back at square one!).
If the smell persists, give it another thorough clean. That, and some time, should be enough to rid your fridge of even the most persistent smells. To prevent your food from absorbing the odors, be sure everything is tightly sealed in jars or plastic containers. Ice cube trays with covers are great if you can find them.
Learn how to properly store leftovers >>
More tips for keeping your fridge clean