Roughly chop the onions. Peel garlic pods and ginger. Transfer these ingredients to a food processor/blender. Pulse or blend until pureed.
Heat oil in a pan. Add cumin seeds. When it starts to crackle
Add onion, ginger, and garlic paste to the pan.
Cook at a medium flame until the color changes from light purple to light brown. Do stir 3-4 minutes so that the paste doesn’t burn or stick to the bottom of the pan. While the onion paste is cooking, wash and roughly chop tomatoes. Add it to a blender and blend until smooth and pureed. After 20-25 minutes of cooking, onions will change its color from light purple to pale brown.
Stir in the pureed tomatoes and mix to combine.
Cook for another 15-20 minutes until all the moisture has evaporated and oil starts to separate from the masala. Keep stirring in between (probably every 5 minutes or so).
When you see a super-thin layer of oil bubbles popping at the edge of the masala, this means it is thoroughly cooked. At this point, the color of the masala will become deep red.
Switch off the gas and allow it to cool. Store in an airtight container in your refrigerator. It freezes beautifully.
If a recipe calls for onion, garlic, ginger, and tomatoes then use 1/4 -1/2 cup of cooked magic masala and voila... you are all set, follow rest of your recipe and your meal will be on the table in no time.