This is Act V, scene i, and it is the first scene in which Hamlet re-appears after he is sent by Claudius to England. He listens to the scene in hiding to begin with, but finally jumps out to challenge Laertes' love for Opheila. It is important to note that Hamlet had no idea, before this moment, that Ophelia was dead.
He, at first, seems to make fun of Laertes' show of grief:
What is he whose grief
Bears such an emphasis, whose phrase of sorrow
Conjures the wand'ring stars and makes them stand
Like wonder-wounded hearers?
But, when Laertes obviously attacks him (Hamlet says: "take thy fingers from my throat" and "Hold off thy hand."), his tone darkens and he stands his ground:
I will fight with him upon this theme
Until my eyelids no longer wag.
...I lov'd Ophelia. Forty thousand brothers
Could not with all their quantities of love
Make up my sum.
And then Hamlet challenges Laertes to prove that his love is more than Hamlet's. It's almost like two kids on the playground proving that one is braver or stronger or smarter than the other. Hamlet lists off challenges to Laertes, claiming that he will also do them all and more:
Woo't weep, woo't fight, woo't fast, woo't tear thyself,
Woo't drink up eisel, eat a crocodile?
I'll do it.
And finally, Hamlet displays his ignorance of the cause of Laertes' anger towards him. He seems to have forgotten that he killed Laertes' father, and that the death of that same father might have had something to do with Ophelia's death as well. He asks Laertes:
What is the reason that you use me thus?
I lov'd you ever.
His final line of the scene seems to foreshadow the final scene of the play, but it is a very curious line, a little hard to decipher. Hamlet says:
...But it is no matter.
Let Hercules himself do what he may,
The cat will mew and the dog will have his day.
So, in sum, it seems that Hamlet's attitude towards Laertes is at first, one of challenging Laertes' right to love Ophelia "most," but then it becomes one of questioning, as he, un-remembering of Polonius' death, asks Laertes why he seems to have something against him, since they were always friends before. Later, of course, Hamlet and Laertes do, in their final moments, reconcile and regain their lost friendship.