An electrical generator and motor are two machines that operate oppositely.
An electrical generator uses mechanical energy, converting it to produce electrical energy. This mechanical energy is provided in most cases from a spinning/rotating action in which a wire or loop of wire spins in a magnetic field. This causes the wire to move sharply through the magnetic field, causing current to flow, and in turn, creating electricity.
An electrical motor does the opposite, but uses the same principles, converting electrical energy to produce mechanical energy. The motor will have an alternating current (AC) moving through pairs of magnets, producing a rotating magnetic field. This causes the motor's central rotor to spin, powering whatever machinery it is hooked up to.