To provide a liquid crystal composition satisfying at least one or having a suitable balance regarding at least two of characteristics such as high maximum temperature of a nematic phase, low minimum temperature thereof, small viscosity, suitable optical anisotropy, large negative dielectric anisotropy, large specific resistance, high stability to ultraviolet light and heat; and an AM device having characteristics such as short response time, a large voltage holding ratio, low threshold voltage, a large contrast ratio and a long service life. A liquid crystal composition has negative dielectric anisotropy and a nematic phase, and contains a compound contributing to high stability to heat or ultraviolet light. The composition may contain a specific compound having large negative dielectric anisotropy as a first component, a specific compound having high maximum temperature or small viscosity as a second component, and a specific compound having a polymerizable group.