This is a very good question because most of us often wonder about it many times. So I am explaining it with an example. It will be a bit lengthy, so please read it with patience. Also make sure to read this answer to get an idea about the three types of karma.
Are our destinies predetermined?
Yes, they are. Destiny means a set of events and experiences that are certain to happen in a particular person's life. So most major events in our lives are predefined. For example, where and to which family we will be born, what type of job we will be doing, what incidents and life we will be experiencing, etc. are predefined.
But, for any event to manifest a certain set of actions are also required. Hence, for the manifestation of certain predefined events, the necessary actions will also have to take place. That is why certain actions are also predefined and these set of preordained actions are known as prarabdha karma. And for the actions to manifest we will need to have that kind of desire and mindset. Hence, people's likings, nature, etc. are also acquired as per their past actions.
For example, due to a past wrong action (stopping the four Sanat kumaras from meeting Vishnu) Sishupal and Vakradanta, in their previous life as a guard in Vaikuntha (abode of Vishnu), got cursed and had to take birth as a demon, and Kamsa in his previous birth was demon Kalanemi and was cursed by Hiranyakashipu. And because they were predestined to be killed by Krishna, most of their actions were destined to be wrong and demonic in nature.
If destiny is predefined, then why do our actions affect our karma?
Indeed true.
- "If whatever I'll do in my life is already predefined, then certainly I shouldn't be held accountable for my actions."
- "After all, it's all fated, why should my actions count? Why should they affect my karma?"
Yes, these are all valid questions. But the point is, not all our actions are predefined. Only those set of actions that will give rise to predetermined events are predefined. And in our life we do both kinds of actions, predefined and not defined. Those set of actions that were not predefined are known as Kriyamana Karma (accumulating actions). It is mostly these actions that affect our karma, not the preordained ones. Generally, preordained events and actions being effects of our past life actions, once experienced, they get balanced out. But the Kriyamana karma, being newer actions that we do in this present life, get stored to be experienced later. Let me give an example for better understanding.
Example
Suppose you had done many good works in your previous life and for that reason you are destined to be wealthy and famous. So, if in this life, you have become an engineer or programmer, then you will feel attracted to develop a software that it will become famous and earn you money. So most of your actions will be towards fulfilling that objective. You will be coding day in and day out and doing a lot of things for it. But along with that you will be doing many other actions that are in no way relevant to your destined objective. For example, you may see a person who needs some help and help him out, scold or abuse someone for no reasons other than out of anger, and many other little things you will be doing that no way contribute to your destined objective.
- So those set of minor and major actions that do not contribute to your destined experience of wealth and fame are stored to be experienced later. (kriyamana karma or agami karma)
- And those set of actions (like coding, planning etc.) that do contribute to your destined objective are generally not considered unless the sense of doership is attached to them. (prarabdha karma)
Let me represent the flow of karma in a diagram:
How can an individual possibly get rid of bad karma if it has already been defined in his destiny?
Unfortunately one can't. There is no way to escape from the effects of actions without experiencing their results. Just like an arrow already shot cannot be taken back, prarabdha karma that has already set out in motion cannot be escaped from. It will catch you sooner or later.
Example:
After knowing Devaki's 8th son was going to kill him, Kamsa tried many tricks, methods and plans. But no matter how hard he tried, eventually he had to meet his destiny.
However, whether prarabdha karma can be avoided or not, depends upon its strength. If one uses his kriyamana actions for acts of penance and expiation (this includes astrological remedies), then those new good actions may cancel out or reduce the strength of prarabdha actions.
Example:
Markandeya rishi was destined to be dead at the age of 16. But he engaged himself in the devotion of Shiva and practised austerity sincerely. Hence, due to his devotion and penance by the grace of Lord Shiva he escaped his certain death.
Also if one realizes Brahman and acquires the knowledge, all his actions are burned away and he becomes free:
yathaidhāṁsi samiddho ’gnir bhasma-sāt kurute ’rjuna
jñānāgniḥ sarva-karmāṇi bhasma-sāt kurute tathā [BG - 4.37]
Meaning
As a blazing fire turns firewood to ashes, O Arjuna, so does the fire of knowledge burn to ashes all reactions to material activities.
However, preordained karma that has been already rolled out, cannot be taken back and one has to experience his prarabdha just for the current life even after realization of knowledge of Brahman. But a true jnani sees everything as Brahman and hence prarabdha doesn't affect his mind:
utpanne tattvavijñāne prārabdhaṃ naiva muñcati
tattvajñānodayādūrdhvaṃ prārabdhaṃ naiva vidyate [Nadabindu Up. - 22]
Meaning
Even after attaining knowledge of the self prarabdha never exhausts out. But after realization of knowledge prarabdha is not felt by the jnani as he considers the body as unreal.
Apart from jnana, by devotion and grace of God also one gets liberation from all his stored sinful actions:
sarva-dharmān parityajya mām ekaṁ śaraṇaṁ vraja
ahaṁ tvāṁ sarva-pāpebhyo mokṣayiṣyāmi mā śucaḥ [BG - 18.66]
Meaning
Abandoning all kinds of dharma if you surrender only to Me, I will give you liberation from all sins, you need not worry.