Fair use is a legal doctrine within U.S. copyright law that permits copyrighted material to be used without the copyright owner’s permission in certain circumstances. Fair use is an affirmative defense to copyright infringement, and thus can be seen as an exception within copyright law. However, fair use can also be seen as a right that is one element of the right to free expression.
Title 17 U.S. Code section 107 states:
Notwithstanding the provisions of sections 106 and 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phonorecords or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright. In determining whether the use made of a work in any particular case is a fair use the factors to be considered shall include—
(1) the purpose and character of the use, including whether such use is of a commercial nature or is for nonprofit educational purposes;
(2) the nature of the copyrighted work;
(3) the amount and substantiality of the portion used in relation to the copyrighted work as a whole; and
(4) the effect of the use upon the potential market for or value of the copyrighted work.
The fact that a work is unpublished shall not itself bar a finding of fair use if such finding is made upon consideration of all the above factors. 
In any case where the use of a copyrighted work may be fair use, the four factors above must be balanced. Unfortunately, there are no bright lines to help us determine when a particular use crosses the line from fair use to infringement. Fair use is a grey area, and the only cases where we know for sure what is fair use and what is not are those that have been ruled on by federal courts.
A central consideration in many fair use cases is whether the use is sufficiently “transformative,” in terms of its purpose and character. The most definitive formulation of this somewhat slippery concept comes from the U.S. Supreme Court’s unanimous ruling in Campbell v. Acuff-Rose Music, holding that parody can be fair use. The Court states that a work is transformative when it does not merely supplant the original, but “instead adds something new, with a further purpose or different character, altering the first with new expression, meaning, or message.” 
A good way to learn what types of uses do and do not constitute fair use is to consult the Fair Use Index provided by the U.S. Copyright Office. The index provides one-page summaries of fair use cases, indicating what use was made of copyrighted material, and whether a court found it fair or not. You may browse all cases, or filter your search by subject matter, such as “photograph.”
Another tool you can use to perform your own analysis of whether a particular use is fair is the Fair Use Checklist (pdf) provided by Columbia University Libraries. As their instructions make clear, the checklist is merely a guide to careful analysis, not a magic formula.