Basil, especially sweet basil or Genoa basil so popular in Italian dishes and used in pesto, is notoriously tricky to keep fresh. It turns black and wilts at an astonishingly quick rate. There are methods, however, of keeping the leaves fresh once the stems have been picked. The fresher the basil you buy, of course, the longer it will keep in any case.
#1 The Very Best Method
Hand's down the best way to store basil in to put the bunch in a glass or jar filled with water, just like flowers.
Trim the cut ends, put the bunch in a glass, jar, or vase of water that will fit in the fridge, and cover the whole thing, or at least the basil leaves, with a plastic bag. Put the whole in in a refrigerator. Basil kept that way will stay vibrant and green for up to a week.
Is it a bit of a pain? Sure. Not super-duper convenient? Fair point. Takes up a lot of fridge space? No one could argue against argue that point. Does it also keep basil as fresh as possible for as long as possible? Absolutely it does.
#2 The Next-Best Method
We've established that the very best method isn't always as practical as one might like. Luckily, there is a second-best-but-still-completely-serviceable choice.
The second best way to store basil is to store it like salad greens: pick the leaves off the stems and lay them in more or less a single layer on layers of paper towels or a clean kitchen towel, roll up the towel around the leaves, and put the roll in a plastic bag. This method keeps the leaves hydrated but not wet or damp. For step-by-step photo details, see How to Store Greens.
#3 Freezing for Longer Storage
Want to keep basil around for more than a few days? Freeze it! There are several ways to do it effectively.
For the greenest, freshest seeming basil: quickly blanch the basil in boiling salt water for 15 seconds, drain it, and dunk it into ice water to cool it quickly (this sets the green color; see How to Blanch for details), and then whirl it in a blender with just a bit of olive oil. You can pour the purée in ice cubes trays, freeze them, and transfer the cubes to re-sealable plastic bags where they keep for up to a year.
Admittedly, that method requires a touch of work. Alternatively, you can simply lay clean, dry basil leaves on a baking sheet, freeze them until frozen (about an hour will do it), and transfer them to resealable plastic bags. Basil frozen this way will turn dark, almost black, but retain plenty of basil flavor. To keep it green, you'll need to blanch it, squeeze it dry, then lay it flat to freeze. Once you bother blanching the basil, though, it's worth making the purée and freezing it that way, since it retains so much more flavor with that method.
See How to Freeze Basil for more details.