By researching Alliances the option becomes available to ally with other races through the diplomacy screen. This is a useful technology, and one you should spread as widely as possible. Why? Simple - the more races with the potential to have alliances, the more likely they are to be dragged into war and thus weakened. So as long as you can stay out of the battles, you'll be the victor in the long run.
In order to form an alliance with another race your current relations must be 'Close' or better, and trading for it in the Trade window. If another civilization declares war on you, your ally will declare war on your attacker. However the opposite applies, if someone declares war on your ally, you will be required to declare war on them, or break your alliance.
To get 'Close' relations, you either need a sum of seven or more in Relation Factors. If you send aid when a civilization begs while under attack of another, it will also bring relations closer, making it much easier to get 'Close'.
Note: No longer seem to be true in Twilight. If you get to "Close" relations, regardless of relation factors, an alliance can be made.
Gaining 'Ally' status with all other surviving civilizations leads to a Diplomatic Victory.