A foil or a foil character differs from one character (in this case, Hamlet) and those differences highlight Hamlet's traits. So, we don't have to look far until we come to Claudius who serves as a foil to Hamlet. Claudius's crime highlights (and causes) Hamlet's need for vengeance. Claudius is the main villain/antagonist in this play and this contrasts with Hamlet's role as the main protagonist. Claudius continues to try to hide his crime, while suppressing Hamlet's role and importance (by sending him away). This is contrasted by Hamlet's desire to expose Claudius for the criminal that he is. These characters are actively working against one another, but they do not communicate this to each other until the very end. This unspoken but active duel fuels the plot and contributes to many themes of the play: murder, secrecy, revenge, madness, and justice.
An interesting side note to this "duel" is that both Claudius and Hamlet are similar in that they both conspire and plot in secret. Each man has an agenda and the best way to achieve his goal is to keep the agenda hidden from others. Hamlet and Claudius do not trust one another, but they hide this suspicion from one another. It is like a chess game. Little by little, Claudius grows more suspicious of Hamlet. Even Polonius shows some suspicion and proclaims it in the famous line, "Though this be madness, yet there is method in't." (II.ii.216) Hamlet tries to hide his plot for revenge under a guise of madness.