In general, and especially in recent decades, a duel is considered an illegal act in most countries. The duel took place at the will of one of the parties —the challenger— to wash away an insult to his honor. The goal was not generally to kill the opponent, but to achieve "satisfaction," for example by restoring one's honor by risking one's life to defend it.
Dueling must be distinguished from combat tests, since the former were not used to determine guilt or innocence, nor did they constitute official proceedings. Dueling was instead generally illegal, despite the fact that in most societies where it was common, it was socially accepted.
The participants in a properly staged duel were generally not persecuted, and in cases where they were, they were not imprisoned for that reason. It was considered that only knights had an honor to defend, and therefore the upper social class was the one who qualified to do it: if a knight was insulted by someone from the lower class, he did not challenge him to a duel, but inflicted some physical punishment or commissioned his servants to do so.