How Transistors Work
Bipolar junction transistors (BJTs) and field-effect transistors (FETs) work basically the same way. The voltage you apply to the input (base, for a BJT, or gate, for a FET) determines whether or not current flows through the transistor (from collector to emitter for a BJT, and from source to drain for a FET).
To get an idea of how a transistor works (specifically, a FET), think of a pipe connecting a source of water to a drain with a controllable valve across a section of the pipe, as shown here. By controlling whether the valve is fully closed, fully open, or partially open, you control the flow of water from the source to the drain.
You can set up the control mechanism for your valve in two ways. The control mechanism can
Act like an on/off switch, either fully opening or fully closing with nothing in between.
Open partially, depending on how much force you exert on it. When it’s partially open, you can adjust the valve a little to allow more or less water to flow from source to drain; small changes in the force you exert on the valve create similar, yet larger, changes in the flow of water. That’s how a transistor acts as an amplifier.
Bipolar transistors work in a similar way: The base acts like the controllable valve shown, controlling the flow of electrons from the emitter to the collector (or, in circuit-speak, the flow of conventional current from the collector to the emitter). By controlling the base, you can turn the transistor fully on or fully off, or you can allow small changes at the base to control large changes in current from collector to emitter.