In Hinduism, karma is of three kinds:
Prarabadha Karma
This karma is unchangeable within the scope of one life, since it is the 'setup' for the life in question. It is the karma of one's past lives. After death, the atma leaves the body, as the casting off of old vestments, and carries with it the samskaras (impressions) of the past life of thoughts and actions and events. These samskaras manifest themselves in the unchangeable situation into which one is born and certain key events in one's life. These include one's time of death (seen as governed by an allotment from birth of the total number of one's breaths for that life), one's economic status, one's family (or lack of family), one's body type and look: essentially, the setting of one's birth, the initial base.
Samchita Karma
The samskaras that one inherits from the last lives create one's personality, inclinations, talents, the things that make up one's persona. One's likings, abilities, attitudes and inclinations are based on the thoughts and actions of past lives. One's samchita karma is somewhat alterable through practice and effort towards change. This might be seen through the Hindu system of yoga and the dynamic of the gunas. An example would be someone who, through meditation, slowly evolved into a more stable personality.
Agami Karma
Agami karma is the karma of the present life over which the soul has complete control. Through it one creates one's karma in the present for the future of the current life and in life-times to come.
The Hindu cannot say, sometimes, if a major event in life is the doing of Prarabadha or Agami Karma. The idea of "bad things happening to good people" is seen by the Hindu as a result of Prarabadha Karma, more simply understood as karma from a past life.
In Hinduism, karma works within a cyclical framework that sees the phenomenal universe being created and eventually dissolving back into itself, back into realization that it was nothing other than Maya imposed on the truth of Brahman. So Karma will eventually be worked out.
Karma does allow for anirudh (Divine Grace). Through exceeding devotion and love of God, the Hindu believes one can be helped to speed through Karma phal (Karmic fruit). By developing 'vairagya' or 'detachment' from the fruits of one's karma, as Lord Krishna most famously summarized, one can transcend karma and be liberated. One is aided by love of God. All the Yogas of Hinduism seek to transcend karma through different means of realization.
Buddhism
In Buddhism, only intentional actions are karmic "acts of will". Often misunderstood in the West as "cause and effect", in actuality, Karma literally means "action" - often indicating intent or cause. Accompanying this usually is a separate tenet called Vipaka, meaning result or effect. The re-action or effect can itself also influence an action, and in this way, the chain of causation continues ad infinitum. When Buddhists talk about karma, they are normally referring to karma that is 'tainted' with ignorance - karma that continues to ensure that the being remains in the everlasting cycle of samsara.
This samsaric karma comes in two 'flavours' - good karma, which leads to high rebirth (as a deva, asura, or human), and bad karma which leads to low rebirth (as a hell-sufferer, as a preta, or as an animal).
There is also a completely different type of karma that is neither good nor bad, but liberating. This karma allows for the individual to break the endless cycle of rebirth, and thereby leave samsara permanently.
This seems to imply that one does not need to act in a good manner. But the Buddhist sutras explain that in order to generate liberating karma, we must first develop incredibly powerful concentration. This concentration is akin to the states of mind required to be reborn in the Deva realm, and in itself depends upon a very deep training in ethical self-discipline.
This differentiation between good karma and liberating karma has been used by some scholars to argue that the development of Tantra depended upon Buddhist ideas and philosophies.
Understanding the universal law of Karma provides order to a beginningless and endless universe. Alongside this view is the related notion of Buddhist rebirth - sometimes understood to be the same thing as reincarnation - which has its roots in the principle of Karma.