Firstly, you also need diodes across the relay coils, cathode end up to supply.
The symptoms you describe are fairly common and caused by noise induced into the microprocessor somehow. The most likely source is the supply lines and if applicable the reset line. I am not familiar with the 89v51rd2 so forgive my lack of direct experience, I use the PIC family but the same problem and reasons apply.
Make sure you have good decoupling across the processor supply pins, and as close to the IC as possible. Use at least 10uF with a ceramic 100nF across it. The closer they are to the chip, the less likely supply noise will cause problems.
If you have a reset line, make sure it is also well filtered.
Although not impossible, it is improbable that the lines driving your transistors have spikes on them. Generally, output pins are not responsible for this kind of issue.
Ensure you have no floating or high impedance input pins which could act as antennas to the interference burst.
Finally, if filtering fails all you can do is go for physical isolation of the micro from the relays. The magnetic field from the relay coils and switched load is inducing voltage into the micro somehow and keeping them apart may be the only solution.
Brian.