The GlueX experiment at Je↵erson Lab has been designed to study photoproduction reactions with a 9-GeV linearly polarized photon beam. The energy and arrival time of beam photons are tagged using a scintillator hodoscope and a scintillating fiber array. The photon flux is determined using a pair spectrometer, while the linear polarization of the photon beam is determined using a polarimeter based on triplet photoproduction. Charged-particle tracks from interactions in the central target are analyzed in a solenoidal field using a central straw-tube drift chamber and six packages of planar chambers with cathode strips and drift wires. Electromagnetic showers are reconstructed in a cylindrical scintillating fiber calorimeter inside the magnet and a lead-glass array downstream. Charged particle identification is achieved by measuring energy loss in the wire chambers and using the flight time of particles between the target and detectors outside the magnet. The signals from all detectors are recorded with flash ADCs and/or pipeline TDCs into memories allowing trigger decisions with a latency of 3.3 µs. The detector operates routinely at trigger rates of 40 kHz and data rates of 600 megabytes per second. We describe the photon beam, the GlueX detector components, electronics, data-acquisition and monitoring systems, and the performance of the experiment during the first three years of operation.