From the very start of the play, the characters of Fortinbras and Hamlet are shown to be foils -- characters that alike and yet different. In Act I, Horatio reveals that Fortinbras is a young, brash prince of Norway who has "sharked up a list of lawless resolutes" to attack Denmark in order for him to regain lands that his father lost in a previous battle with the old King Hamlet. Fortinbras is showing himself to be shrewd in planning his attack during a time of mourning and confusion in Denmark due to the recent death of King Hamlet and the subsequent transfer of power to his brother, King Claudius. He is also showing that he is not going to necessarily follow "the rules" -- he has hired mercenaries to be his army -- looking for men who are willing to do whatever it takes. We learn in Act 2 that Fortinbras has agreed to not attack Denmark but has asked for "safe passage" through Denmark so that he may go towards Poland to fight for a piece of land there. This may or may not be true, but it serves Fortinbras well if he would want to change his mind, break the truce, and fight anyway. When Hamlet actually sees him and learns more about him in Act 4 we see that Hamlet admires the young prince. Hamlet recognizes that Fortinbras is willing to risk a lot in order to regain what was lost. He is literally fighting over a worthless piece of land which "has no profit but the name." Hamlet is actually kind of inspired to 'do what he has to do' to avenge his own father's death by the observation of Fortinbras. Hamlet does his own comparisons when in the scene in Act 4 he condemns himself for his lack of action (in direct opposite of the "active" Fortinbras). He says that he, himself, is a coward in comparison to Fortinbras who "with divine ambition puffed" is willing to risk everything. Hamlet acknowledges that he has been slow to act and let events get in his way. By the end of the speech though he declares, "my thoughts be bloody or be nothing worth!" It would appear that Fortinbras has sparked some drive in Hamlet.
In the end of the play it is Fortinbras, in an ironic twist, who will take over the throne of Denmark. This act restores a measure of order to the kingdom, but it is troubling that Denmark is now ruled by a foreigner who claims he only has "some rights of memory here." But this was Hamlet's dying statement, so we can take some comfort in that.
The two princes have a lot in common. Firstly, they are both a menace to Denmark, now ruled by the murderous Claudius: Fortinbras is invading the sacred space of the Danish kingdom from outside; Hamlet is undermining the certainties and the false pretences of the court from within. Secondly, they portray youthful rebels against the powers-that-be, embodied by Claudius and Polonius especially. Thirdly, they are newcomers to the old game of politics, powerful outsiders who will strike robust blows against the empire.
However, there are also important differences: although Hamlet clearly admires Fortinbras for his dedication and willingness to act, he also underlines the deep gulf between them by undertaking his “revenge” in a very original way. Fortinbras is a man of action and war; in a way, he follows the old tradition of conquering land with violence and solving disputes through bloodshed. On the contrary, Hamlet is a modern ideologist who knows that action is useless because it only reproduces the status quo; he is neither a passive, half-hearted son, nor an irresolute, doubtful prince. Through his acting and fake madness, he reveals the total absurdity of life and the sadness of our existence, together with the utter hypocrisy of power - and love, and filial affection, too. If Fortinbras is as firm and unswerving as metal, Hamlet shows the flexibility of thought and philosophy. The former is brave enough to wage wars against his enemies; Hamlet is even braver because he decides to use language to destabilise the false certainties of the court, putting his very self at risk and questioning his past, present and future; it takes much more courage.
The difference between them is all the more striking in the final scene: when Hamlet is dying, he proclaims Fortinbras to be king but his fondest thoughts are for Horatio (“… draw thy breath in pain, / To tell my story.”). When he dies, Horatio wants to show the effects of violence and war to act out a sort of reparation for Hamlet’s sacrifice and “wounded name”; Fortinbras, now commanding the stage, orders the bodies to be taken out of sight, instead. The utter savagery of humanity, which Hamlet contributed to disclose, is once again removed and hidden away from our eyes.