In a solenoid valve the axially movable magnet armature (driving piston) is connected through an actuating ram with a valve head which is movable between two valve seats and which is urged against the electromagnet force by a spring-biased counterpiston engaging said valve head at its end remote from said ram.