Driving a relay is a very common and relatively simple thing to do. So I thought a quick Google search would turn up lots of documents that explain it simply, clearly and thoroughly. I was half right - there are lots of documents!
The best I found after a quick search was
http://mbed.org/users/4180_1/notebook/relays1/
This page has some other information that you might find interesting as well. Have a good careful read of the first part, at least.
The first diagram shows the general arrangement - a current limiting resistor feeding the base of an NPN transistor, with the emitter grounded, and the relay coil connected between the collector and a positive supply rail, and a diode across the coil to protect the transistor against "back EMF" when the relay is turned OFF.
The supply voltage for the relay coil must be the same as the relay coil's rated voltage. This is often 5V or 12V. It is better to use 12V if you have 12V available, and it's not a good idea to use a 5V logic supply rail (or 3.3V - that's a very bad idea) for the relay, because of the surges that occur when the relay turns on and off, and if an insulation breakdown occurs, which could disrupt or even damage the semiconductors.
The relay coil will have a rated current, as well as a rated voltage. This tells you how much current the transistor will have to pass when it turns the relay ON.
The back EMF diode is needed. You need a diode with a current rating comfortably higher than the relay coil current rating. Generally people use a 1N4001 or similar, which is a general purpose 1A silicon diode.
The 0V rail of this circuit must be connected to the 0V rail of your Raspberry Pi.
The transistor must be rated to withstand the relay coil supply voltage; all general purpose transistors have no problem with 12V or 24V. It must also be rated to carry the relay coil current. This is the Ic (collector current) specification. Typical transistors for relay driving are BC547B and BC337 (UK and Europe, 100 and 500 mA maximum collector currents respectively), 2N3904 and 2N4401 (USA, 200 and 600 mA maximum collector current), and 2SC1815 and others (Japan). You don't say where you're located.
You choose the base resistor to supply enough current to saturate the transistor when driving the specified current through the relay. Let's assume the relay coil is rated at 50 mA and you're using a 2N3904, which has a minimum current gain (Hfe) of 60 at 50 mA collector current. Divide the collector current by the gain, you get 0.83 milliamps. To saturate the transistor you need to feed several times that much current into the base. Let's say five times as much, which is 4.2 milliamps.
Assuming your Raspberry Pi's GPIO swings to +3.3V when it's high, and the transistor's base-emitter voltage is about 0.7 (a good rule of thumb at low currents), you will have 2.6V across the resistor. From Ohm's Law (R = V / I), resistance is 2.6 / 0.0042 which is 624 ohms. Closest lower preferred values are 620 ohms and 560 ohms.
You also need to check that the Raspberry Pi's GPIO is rated to deliver at least 4.2 mA from its output.
You can also use a MOSFET as the switching element. These draw no current from the GPIO pin, which seems like an advantage, but it also means that they could float and activate spuriously if the GPIO pin is tri-stated or in input mode, which might happen during reset, for example. A pulldown resistor can be added to prevent this. Also, MOSFETs that will saturate at 3.3V gate voltage are a bit unusual. Finally, modern MOSFETs are mostly SMT (surface-mount technology) and aren't as easy to work with as big ol' transistors in TO-92 package with three wire leads.
You can also use a Darlington transistor to drive a relay. This has the advantage of low base current, so low loading on the GPIO pin, but you lose about 1~1.5V in the transistor, so your relay doesn't see all of the supply voltage. This isn't normally an issue. Darlingtons are covered on the page I linked to, I think. I often use the MPSA14 which is widely available and rated at 500 mA collector current, I think.