Less technical answer (i.e. step-by-step): I prefer to teach people about MOSFETs since they just need a voltage. No need for complex resistor calculations (e.g. transistor).
Primary step: get another power supply just for the relay. Connect the ground of your Pi and the ground of the power supply together.
WARNING: Refer to your datasheets when choosing the correct voltages. In this answer, I'm using an NPN (N-channel) MOSFET connected as a low-side switch. Assume power supply is 5V. Make sure your MOSFET is rated above your power supply's voltage for safety (i.e. don't get a 5V MOSFET if your power supply is 5V).
Assume I'm using a logic-level MOSFET for simplicity sake. You can also get a logic-level MOSFET for simplicity.
Assume my mechanical relay will switch at 5V.

MOSFET
Attach a 1k resistor to the gate pin. Then, attach the other side of the resistor to the GPIO pin of your choice.
Connect the source to ground.

RELAY
Connect the drain pin of the MOSFET to either pin A or pin B (i.e. either pin of the coil pins) of the relay.
Attach the other coil pin to your external power supply's positive rail/connector/pin/whatever.
Attach the marked (usually with a white/black band) part of your diode to the coil pin that's connected to positive. Attach the other end to the other coil pin.
Overview:
+---------------------+ +-------------+
+-------------+ | NO pin+-----------+Wire end B |
|Wire end A +----------------+COM pin | +-------------+
+-------------+ | |
| | +-------------+
|Coil Coil NC pin+-----------+Wire end B |
++---------+----------+ +-------------+
| |
+---------+
| Diode |
PositiVe | |
+------------------+-----------+ Drain pin
| | +--------+
|POWER SUPPLY | +--------+ MOSFET |
| | | Source--------+Gate pin
+------------------+--------+ Pin |
Negative| S 1K resistor
| |
| +---+------------+
| | GPIO pin |
| | |
+-----------> |Ground Pin |
+----------------+
Raspberry Pi
Your Pi is now ready to power external devices. Just connect one end of a connection (Wire end A on the diagram) and attach the other end (wire end B) to either the NO or NC pin.
- The NO (Normally open) pin is high when the GPIO pin is high.
- The NC (Normally close) pin is low when the GPIO pin is high.
+------------------------------------------------------+
| |
| +---------+ +---------+ +-----------+ |
| | | | | | | |
+---+ Battery +-------+ Relay +------+ Lightbulb +---+
+---------+ +---------+ +-----------+
Wire end Wire end
A B
Image sources: MOSFET | Relay