There are 3 possible diplomatic relationship types between players: Peace, War and Alliance.
War is the default relationship - after all, we're here to kick each other's butt, right? When you're in war, you can freely attack your opponent and cannot pass through his troops or defence lines without attacking them.
Peace means you cannot attack without declaring war first - which takes one turn. This gives you some protection against sudden backstabbing. You can freely pass through troops and defence lines.
Alliance offers twice more protection against backstabbing - since it takes 2 turns to change to War. While in alliance, you can send money to each other and see all each other's troops, even those beyond your visibility range. It's also possible to pass empty cities between allies. You can also achieve joint victory, if all opponents have been defeated and only allied players are left. This can also be a way to 'draw' the game.
Changing diplomatic relationship
Open the Players menu and click on some player. A panel would expand, with diplomacy options. Changing relationship to Peace (from War) or to Alliance requires the other player's confirmation. Once the next turn starts, he can either confirm or reject the change.