Foil

In literature, a foil is a character who contrasts another character, usually the protagonist, in certain ways. In can be negatively or positively.

Examples
Piggy is a foil to Ralph in Lord of the Flies because he is thoughtful and methodical, while Ralph is headstrong and determined.

"Jack started to protest but the clamor changed from the general wish for a chief to anelection by acclaim of Ralph himself. None of the boys could have found good reason for this; what intelligence had been shown was traceable to Piggy while the most obvious leader was Jack."

Synonyms

 * deuteragonist
 * side-kick