In summary, from Chillingeffects.org, here is the relevant section concerning the Fair Use doctrine:
Copyright and Fair Use
When a copyright holder sues a user of the work for infringment, the user may argue in defense that the use was not infringement but "fair use." Under the fair use doctrine, it is not an infringement to use the copyrighted works of another in some circumstances, such as for commentary, criticism, news reporting, or educational use. The defense generally depends on a case-by-case judgment of the facts.
Fair use is codified at Section 107 of the Copyright Act, which gives a non-exclusive set of four factors courts will consider in deciding whether a use is fair or not. These factors are
1. the purpose and character of the use,
2. the nature of the copyrighted work,
3. the amount and substantiality of the portion used, and
4. the effect of the use on the potential market for or value of the copyrighted work.
Of course, even with these factors, it is problematic and often unyielding to try to predict what uses a court will deem fair.
The case law is often quite unpredictable, and even contradictory about how it interprets these four factors.