The first Middle-earth story Tolkien published during his lifetime was The Hobbit.
The Hobbit appeared in 1937 and introduced readers to Bilbo Baggins, Gandalf, Thorin Oakenshield, Smaug, and many elements of the setting later called Middle-earth. Tolkien had been developing related legends and languages for years, but The Hobbit was the first major work from that mythology to reach a broad reading public.
The novel began as a children’s fantasy adventure rather than as a direct presentation of Tolkien’s full mythology. Its success led George Allen & Unwin to ask for a sequel. Tolkien initially worked on a continuation, but the project grew into the much more expansive narrative of The Lord of the Rings.
The Silmarillion was assembled and published after Tolkien’s death, so it does not qualify as the first lifetime publication. Leaf by Niggle is also a Tolkien work, but it is a separate short story rather than the first published Middle-earth narrative.