Peace Treaties prevent your town from being attacked for a given duration. They are awarded when an opponent earns at least one star against you during an attack.  The duration of the treaty is related to the number of stars awarded. Peace treaties can last from 8-16 hours.
Peace Treaties can also be acquired via the Store, using Crowns.

What does 'Peace Treaty Cooldown' mean?
‘Peace Treaty Cooldown’ refers to the amount of time a player must wait before they are able to purchase another peace treaty in the Store.