Huck Finn is caught in between two types of morality, his own native sense of what is right and the moral code of his society. This has been called a conflict between "moral law" and "civil law". A number of passages express this conflict and Huck's consideration of it.
Early in the novel, Huck finds Jim on the island. When Jim prepares to tell Huck the story of how he escaped slavery and ran away, he swears Huck to secrecy. This makes Huck an accomplice in Jim's escape, a fact that is morally troubling for Huck.
People would call me a low-down Abolitionist and despise me for keeping mum—but that don't make no difference. I ain't a-going to tell...
Society has made slavery legal and has decided upon penalties for breaking laws regarding slavery. Huck understands these laws as moral dictates and so feels morally compromised by protecting Jim. In his own eyes, Huck is open to being "despised".
Yet, Huck does keep Jim's secret. His own sense of morality suggests that helping Jim is fine. They are both run-aways after all, seeking some kind of freedom.
Later, Huck is troubled by the moral implications of helping Jim escape from the Phelps house after he has been sold by the King and the Duke.
He feels terrible for “stealing another person’s property,” namely Jim, who as a slave was indeed Miss Watson’s “property.”
Unable to overcome his respect for society's moral code, Huck is nonetheless able to act according to his own conscience, placing friendship above social mores. His reflections lead to him to consider this friendship and, soon after, to decide he'd rather "go to hell" than abandon Jim.
...[Jim] would always call me honey, and pet me, and do everything he could think of for me....and said I was the best friend old Jim ever had in the world, and the only one he's got now...
These passages demonstrate Huck's challenge to find the right path to take in situations where the "proper action" is unclear because his own native moral sense suggests a different course of action than society's rules, laws, and morality.
Other passages demonstrate the same dilemma, including Huck's time with the King and the Duke, the Wilks family, and the Grangerford family. In each situation Huck is pressed to decide between loyalty to one sort of morality or another.
Will he stand by the King and the Duke despite the fact that they are frauds out to hurt other people? Or will be resist the urge to "betray" them because his social code tells him that any betrayal would be wrong, even if these are not his friends?
These questions arise in various forms throughout the narrative.