A Mary Sue (sometimes just Sue), in literary criticism and particularly in fanfiction*, is a fictional character with overly idealized and hackneyed mannerisms, lacking noteworthy flaws, and primarily functioning as wish-fulfillment fantasies for their authors or readers. Perhaps the single underlying feature of all characters described as "Mary Sues" is that they are too ostentatious for the audience's taste, or that the author seems to favor the character too highly. The author may seem to push how exceptional and wonderful the "Mary Sue" character is on his or her audience, sometimes leading the audience to dislike or even resent the character fairly quickly; such a character could be described as an "author's pet."
"Mary Sues" can be either male or female, but male characters are often dubbed "Gary Stu," "Marty Stu," or similar names. While the label "Mary Sue" itself originates from a parody of this type of character, most characters labeled "Mary Sues" by readers are not intended by authors as such.
While the term is generally limited to fan-created characters, and its most common usage today occurs within the fan fiction community or in reference to fan fiction, original characters in role-playing games or literary canon are also sometimes criticized as being "Mary Sues" or "Canon Sues," if they dominate the spotlight or are too unrealistic or unlikely in other ways. One example of this is Wesley Crusher from Star Trek: The Next Generation.
*very particularly. But am anxiously awaiting Stanley Fish's upcoming op-ed on the Mary Sue in postmodern fiction. Or the retro-identification of Sues in pre-fanfiction. This blog's nomination would be Esther Summerson in Charles Dickens' Bleak House. This entire category seems to have been invented for Wesley Crusher. Sorry to be snotty but "Canon Sues"?--ugh.