After 2,000 years of fighting the Children of the Forest and the First Men end up calling a truce and making a pact. The Children of the Forest would inhabit the deep woods and the First Men promised not to chop down any more weriwood trees, in return they could inhabit the rest of Westeros in peace.
The Pact began 4,000 years of friendship and peace between the two peoples. This is known as the Age of Heroes. During this time the First Men took took up the same gods as the Children of the Forest.