2001 Mazda Tribute stalls/engine light on during heavy rain

Hello:

I am having a problem with my 2001 Mazda Tribute when it rains very hard and after driving for a few hours the engine light will come on, the car begins to lose power, jerks and eventually stalls out. This has happened twice in the last year during heavy downpours. Both times I had to be towed. Does this sound electrical or perhaps something is not sealed properly which is letting in water? The car will restart but does not stay running. Thanks for any suggestions.