A solenoid valve is an electromechanical device used to control the flow of liquid or gas. It uses a coil of wire that, when energized, creates a magnetic field that pulls a plunger or valve mechanism to open or close the valve.