In a solenoid valve, a bobbin and a solenoid coil are accommodated in a casing. A rod-shaped plunger is slidably inserted into the bobbin. A core provided with a flow port through which a fluid flows is disposed on one side of the casing. A valve body is attached to one end opposing the flow port of the plunger. In a non-operating period during which a solenoid coil is in a non-energized state, the valve body moves away from the flow port due to the biasing force applied by the biasing portion and another end of the plunger protrudes outward from the casing through the through hole, abuts against lock portions disposed outside of the casing, and is thereby locked. The lock portions can be elastically deformed by an external force such that separation of the plunger and the valve body from the casing is allowed.