The Hobbit was published before The Lord of the Rings.
George Allen & Unwin published The Hobbit on 21 September 1937. Tolkien wrote it as a children’s fantasy story about Bilbo Baggins, a hobbit drawn into a quest involving dwarves, the dragon Smaug, and the recovery of treasure.
The book’s success led Tolkien’s publisher to request a sequel. Tolkien initially worked on a continuation, but the project grew into the much larger story eventually titled The Lord of the Rings. That work was published in three volumes between 1954 and 1955.
The Hobbit is sometimes treated as simply the first part of The Lord of the Rings, but it is a separate novel with a lighter tone and a different narrative structure. Bilbo’s discovery of the Ring connects the two works, while their plots remain distinct.