Lipopolysaccharide (LPS) in the outer membrane of Gram-negative bacteria is critical for the assembly of their cell envelopes. LPS synthesized in the cytoplasmic leaflet of the inner membrane is flipped to the periplasmic leaflet by MsbA, an ATP-binding cassette transporter. Despite substantial efforts, the structural mechanisms underlying MsbA-driven LPS flipping remain elusive. Here we use single-particle cryo-electron microscopy to elucidate the structures of lipid-nanodisc-embedded MsbA in three functional states. The 4.2 Å-resolution structure of the transmembrane domains of nucleotide-free MsbA reveals that LPS binds deep inside MsbA at the height of the periplasmic leaflet, establishing extensive hydrophilic and hydrophobic interactions with MsbA. Two sub-nanometre-resolution structures of MsbA with ADP-vanadate and ADP reveal an unprecedented closed and an inward-facing conformation, respectively. Our study uncovers the structural basis for LPS recognition, delineates the conformational transitions of MsbA to flip LPS, and paves the way for structural characterization of other lipid flippases.