In psychology and ordinary language, guilt is simply a negative affective state in which one experiences regret at having done something one believes one "should not" have done. Guilt and its causes, merits, and demerits is a common theme in psychology and psychiatry. It is often associated with depression.
In criminal law, sometimes in individual and religious moral codes, and more rarely in systems of ethics (either as a philosophical discipline or in ethical codes and professions relying on them), guilt is a concept similar to the economic concept of debt. Actions of low or negative legal value that cause damage on the object, put an equal amount of guilt on the agent. Value theory addresses these questions directly.
Guilt can sometimes be remedied by punishment (a common legal action and advised or required in many legal codes), by forgiveness (as in transformative justice), or by sincere remorse (as with confession in Catholicism or restorative justice). Law does not usually accept the agent's self-punishment, but some ancient codes did so: in Athens the accused was permitted to propose his or her own remedy, which might in fact be a reward, while the accuser proposed another, and the jury chose between. This forced the accused to effectively bet on his support in the community - as Socrates did when he proposed "room and board in the town hall" as his fate. He lost, and drank hemlock, a poison, as advised by his accuser.
Traditional Japanese society and Ancient Greek society are sometimes said to be "shame-based" rather than "guilt-based" in that the social consequences of "getting caught" are seen as more important than the individual feelings or experiences of the agent. This may lead to more of a focus on etiquette than ethics as understood in Western civilization. This leads some to question why them we would adapt the words ethos and mores from Ancient Greek when their norms are so different from ours. A meta-wikipedia article asks this.
Christianity and Islam inherit most notions of guilt from Judaism, Persiann and Roman ideas, mostly as interpreted through Augustine who adapted Plato's ideas to Christianity. The Latin word for guilt is culpa, a word sometimes seen in law literature, e.g. in "mea culpa", "I take responsibility". The Latin word for authority assumes a high degree of responsibility, the English word "province" being a close equivalent.
The relationship between guilt, social trust and the law is complex. A nearly universal notion is that guilt cannot accrue by ignorance except remarkably by ignorance of the law - giving law special status in any ontology. This notion alone explains why religious moral codes and the legal codes of civilizations have tended to evolve closely together.
Some thinkers have theorized that guilt is used as a tool of social control. Since guilty people feel they are undeserving, they are less likely to assert their rights and prerogatives. Thus, those in power seek to cultivate a sense of guilt among the populace, in order to make them more tractable. This was a theme in Eric Hoffer's True Believer. Ayn Rand claimed that Christian sexual morality served a similar purpose.
Another common notion is that guilt is actually assigned by social processes like a jury trial, i.e. that it is a strictly legal concept. Thus the ruling of a jury that O. J. Simpson or Julius Rosenberg was "guilty" or "not guilty" is taken as an actual judgement by the whole society that they must act as if he were so. By corollary, the ruling that such a person is "not guilty" may not be so taken, due to the asymmetry that assumes one is innocent until proven guilty and prefers to take the risk of freeing a guilty party over convicting innocents.