The official website for The Settlers of Catan

Question about Base Game Gameplay - May I ally with another player against a third player?

Answer

The rules do not prohibit it. However, common sense should tell you to play in such a way that your current opponents will also want to play with you tomorrow.