Press the sauté button on the Instant Pot, adjust the heat to the highest setting, then add the oil to the pot. Wait for the oil to get hot, then add the onions.
Cook the onions for 15-20 minutes, stirring occasionally, until browned (keep the stirring to a minimum in the beginning to brown the onions faster. As the onions brown, stir more frequently).
Add the garlic and ginger and stir-fry for 1-2 minutes.
Add the tomatoes and cook for another 3-5 minutes or until the tomatoes cook down a bit. Stir the bottom of the pot to scrape off any brown bits. Add the water and mix well.
Add the spices, give everything a good stir, then secure the lid, close the pressure valve and cook for 5 minutes at high pressure.
Naturally release pressure.
Blend the masala using a blender or an immersion blender (it can be smooth or slightly chunky - up to you!). The sauce will continue to thicken a bit as it cools.
Once the masala is cool, I store it using this silicone mold which holds ¼ cup of onion masala per mold. Then go check out all of my onion masala recipes!