Mary Sue is the title given to a female character – usually in fanfiction, but also in many other realms such as role play and original fiction – who has special powers, beliefs, and relationships with other characters. She is most often beautiful, or at the very least exotic; and her attitudes, although they vary, are usually a mixture of toughness and almost divine sweetness. She is also usually more intelligent than others. A canon character, whether or not it makes any sense, will often fall in love with her. Her almost surreal knowledge of the other characters' inner workings allows her to solve even complex emotional problems with relative ease. She is also prone to having powers that are uncommon in the series, or that are thought to be, or known to be, unique to one character in canon (i.e. Sam's visions in Supernatural or Jedi powers in Star Wars).
Mary Sue is often the star of self-insertion fics.
Her male counterpart is often known as Gary Stu, although there are a variety of names used to describe said character.
Fics (fiction, often fanfiction) starring Mary Sue are called Mary Sue fics, and are generally centered around romance. The title of Mary Sue Fic is most often used to criticize rather than to praise.