Before we proceed any further, let's take a moment to examine what a Mary Sue really is. A Mary Sue is what happens when the author of a story mistakenly believes that making a character special automatically makes them interesting, likable, and relatable. Mary Sues are often their authors' idealized versions of themselves. Mary Sues demand admiration and respect from their readers, despite not having any traits worthy of admiration or respect. And in case you're wondering, Mary Sues do have male counterparts, known as Marty Sams, Marty Stus, or Gary Stus. You don't see them around as much, though.

Just because a character has some Sue-ish traits does not automatically make them a Mary Sue. Someone once said of Sues, "Good characters exist to serve the story. Mary Sues exist to have the story serve them."

A Mary Sue is born when an author's love for and/or identification with a fictional character causes the author to set that character above whatever aspects of rules and realism the author finds undesirable. The more that the author exalts this "darling" at the expense of the rest of the story, the more of a Mary Sue the character becomes. Mary Sue is impervious to failure and resistant to all in-story attempts at criticism and humiliation; any attempt at an external critique usually provokes an authorial temper tantrum. With a preference for style over substance, attitude over empathy, and romantic relationships above all others, the Mary Sue is nevertheless a popular character type due to her function as cheap wish-fulfillment. ~heave_ho's profile on LJ

The PPC Wiki's Mary Sue article lists three essential traits that all Mary Sues have (paraphrased, and with my own examples):

One: Mary Sues don't react realistically to their situations.

A Mary Sue who's never been to sea in her life dreams of becoming a pirate, conveniently ignoring that pirates are bloodthirsty criminals. A Mary Sue insists her parents are evil for encouraging her to accept a marriage proposal from a man she doesn't love, even though they're just trying to give her a good and stable future. A Mary Sue who's been captured insults her captors, instead of keeping quiet so as not to anger them. A Mary Sue gets excited once she discovers she's been sent back in time to the 18th century, instead of freaking out and wanting to go home.

Two: Other characters don't react realistically to Mary Sues.

In Suefic, Jack allows a young woman with no prior nautical experience to join his crew, Will forgets his love for Elizabeth and runs off with a random girl, and Norrington is so moved by his newest prisoner's beauty and charm that he lets her go. You get the picture.

Characters who like the resident Mary Sue, even when they have no reason to do so, are good. Characters who dislike the Mary Sue, typically for illogical or out-of-character reasons, are either bad or eventually won over. The Mary Sue forces the world to revolve around her. She inspires love or hatred in everyone she meets. No one is ever indifferent to or unimpressed by her.

Three: Mary Sues are special just because they exist.

Mary Sues never have to face consequences for their actions. No matter how cruel or selfish their behavior is, how many canon rules they break, or how much better than the canon characters they are at everything, everyone still loves them and thinks they're the most amazing people ever. Nothing is ever the Mary Sue's fault. She never has to face any real challenges or obstacles, which makes for a boring character, and therefore a boring story.