The letter of the law versus the spirit of the law is an idiomatic antithesis. When one obeys the letter of the law but not the spirit, one is obeying the literal interpretation of the words (the "letter") of the law, but not the intent of those who wrote the law. Conversely, when one obeys the spirit of the law but not the letter, one is doing what the authors of the law intended, though not necessarily adhering to the literal wording.
with the spirit, as well as the letter, of the law = dentro do espírito e dos termos da lei
letter and spirit of the law = letra e espírito da lei