"Mary Sue" fanfiction is a type of story in which the fan author inserts an original character who is an idealized stand-in for the author into a piece of fan fiction. The term is not a compliment.

Original characters, or even self-insertion characters, are not necessarily Mary Sues (or Marty Stus / Gary Stus, if male).

The Mary Sue (or Marty Stu) character is either tougher, smarter, and cooler than the established characters but wins their admiration, or nicer, sweeter, and more charming than the established characters and wins their love. Either way, the setting's protagonists are upstaged by a perfect character. If the new character dies in the story, there is extensive grieving.

Most Mary Sues are stereotyped female characters. Some Mary Sues arrived without reason within the setting(another dimension), and invoke powers impossible in the canon. Although Mary Sues are plenty, Mary Sue Parodies were frequently written also, to mock the Mary Sues.

Television shows that have generated large bodies of fan fiction have included episodes that draw on the Mary Sue cliches, including the Star Trek: The Next Generation episode "Hollow Pursuits" and the Buffy the Vampire Slayer episode "Superstar". Some fans have suggested that Wesley Crusher was Eugene Wesley Roddenberry's Mary Sue character, though by definition, this is a contradiction in terms.

The term Mary Sue was said to have originated from a Star Trek fanfiction bearing the first original Mary Sue (with that same name).