Patrick and Gary are friends and revealed to be cousins. Also, Gary leaves SpongeBob for Patrick in the episode "Dumped," until it is revealed at the end of the episode that Gary just wanted the cookie in his pocket. Patrick also helps SpongeBob find Gary in "Have You Seen This Snail?," though doesn't wind up being that helpful and encounters him at the arts & craft store but is too dumb to tell SpongeBob.
Even though their friendship seems nice, Patrick can also be very harmful to Gary. An example is in "Pet Sitter Pat," when he tries to force Gary to take a bath and tries to dry him with a blow torch. They are both mean to each other in that episode until the end where Gary reads Patrick a bedtime story even after all he has done. In "Yours, Mine and Mine" he removed Gary from his friend list, however Gary didn't care.