In 1971, the Supreme Court heard the case of Lemon v Kurtzman (403 US 602). In the case, the Court decided that a Rhode Island law that paid some of the salary of some parochial school teachers was unconstitutional. The case is discussed in more detail on the Constitution and Religion Page. One of the results of this case is the Lemon Test. The Lemon Test is used to determine if a law violates the 1st Amendment.
The Lemon Test is not immutable - there is discussion in the general public and on the current Court about the Lemon Test. However, it has stood as a good guide for lower courts ever since 1971.
The following paragraph is taken from the Lemon v Kurtzman opinion and establishes the rules of the test:
Three ... tests may be gleaned from our cases. First, the statute must have a secular legislative purpose; second, its principal or primary effect must be one that neither advances nor inhibits religion; finally, the statute must not foster an excessive government entanglement with religion.