Moral ambiguity refers to a situation in which there is no clear moral action, no definite "right and/or wrong" course of behavior. This novel features a young man who is repeatedly placed in situations of moral ambiguity where he is challenged to distinguish the proper course of action for himself.
Huck's central dilemma in the novel relates to his efforts to balance his natural sense of morality with society's morality (including issues of legality and crime). The episode involving freeing Jim from captivity is the final challenge for Huckleberry Finn.
It is in this episode that Huck decides there is no "right" course of action. He acknowledges the moral ambiguity of the situation after Jim is sold for forty dollars by the Duke and the King. He considers the contradictory moral facts of Jim's situation: 1) Miss Watson owns Jim and therefore helping Jim escape is a crime. 2) Jim is a good person with a family in Missouri and Huck is in a position to help him return to that family.
It is wrong to help Jim escape. It is wrong not to. This is Huck's dilemma. He considers the idea that no matter what he decides to do, his conscience will bother him. This is when he decides to follow his own impulses and to act on friendship.
"All right, then, I'll go to hell."
To help Jim escape, Huck accepts a sense of guilt because he is committing a crime and helping to rob Miss Watson of her property.
Huck shoves his guilt feelings aside, and resolves to "steal" Jim out of slavery, but he is still convinced that this is a shameful course.
The announcement that Jim has already been declared free that comes late in the novel serves to enhance the ambiguity of the situation. One might assume at first that this announcement would simplify the moral situation because helping Jim escape is no longer a crime. However, Huck acted on the knowledge that freeing Jim was a crime. Questions remain as to the morality of Huck's intentions and his willingness to commit a crime.