Bezos and Musk - the world's first and third richest people respectively, according to Forbes - were competing to lead humankind's return to the moon for the first time sine 1972.
Musk's SpaceX bid alone while Amazon.com founder Bezos's Blue Origin partnered with Lockheed Martin Corp, Northrop Grumman Corp and Draper. Dynetics is a unit of Leidos Holdings Inc.
"NASA Rules!!" Musk wrote on Twitter after the announcement.
The U.S. space agency awarded the contract for the first commercial human lander, part of its Artemis program. NASA said the lander will carry two American astronauts to the lunar surface.
"We should accomplish the next landing as soon as possible," Steve Jurczyk, NASA's acting administrator, said during the video conference announcement.
"If they hit their milestones, we have a shot at 2024," Jurczyk added.
NASA said SpaceX's Starship includes a spacious cabin and two airlocks for astronaut moon walks and that its architecture is intended to evolve to a fully reusable launch and landing system designed for travel to the Moon, Mars and other destinations in space.
SpaceX also responded on Twitter, writing, "We are humbled to help @NASAArtemis usher in a new era of human space exploration."
Unlike the Apollo landings from 1969 to 1972 - the only human visits to the moon's surface - NASA is gearing up for a longer-term lunar presence that it envisions as a steppingstone to an even more ambitious plan to send astronauts to Mars. NASA is leaning heavily on private companies built around shared visions for space exploration.
SpaceX will be required to make a test flight of the lander to the moon before humans make the journey, NASA official Lisa Watson-Morgan told reporters.
NASA had been expected to winnow the lunar lander contest to two companies by the end of April, but instead it picked only SpaceX, a move that deepens their cooperation. On Thursday, NASA said it would send its crew to the International Space Station aboard a SpaceX rocket on April 22.
The agency aims to create regular service to the moon and said it will have a separate competition for that contract.
"We have to be able to provide for recurring lunar services," said Mark Kirasich, deputy associate administrator for NASA's Advanced Exploration Systems division.
The announcement added to an extraordinary run for Musk, who has turned electric car maker Tesla Inc. into the world's most-valuable automaker, with a market capitalization of $702 billion.
Musk has become a one-person technology conglomerate, launching or controlling companies pursuing space flight, electric cars, neural implants and subterranean tunnel boring.
A factor in the choice of SpaceX was "what's the best value to the government," said Kathy Lueders, associate administrator for NASA's Human Exploration and Operations Mission Directorate.
NASA said in a news release that SpaceX's HLS Starship, designed to land on the moon, "leans on the company's tested Raptor engines and flight heritage of the Falcon and Dragon vehicles."
NASA's decision was a setback for Bezos, a lifelong space enthusiast who is now more focused on his space venture after having announced in February he would step down as Amazon CEO.
The contract was seen by Bezos and other executives as vital to Blue Origin establishing itself as a desired partner for NASA, and also putting the venture on the road to turning a profit.
Musk has outlined an ambitious agenda for SpaceX and its reusable rockets, including landing humans on Mars. But in the near term, SpaceX's main business has been launching satellites for Musk's Starlink internet venture, and other satellites and space cargo. SpaceX announced on Wednesday it had raised about $1.16 billion in equity financing.
An uncrewed SpaceX Starship prototype rocket failed to land safely on March 30 after a test launch from Boca Chica, Texas. The Starship was one in a series of prototypes for the heavy-lift rocket being developed by SpaceX to carry humans and 100 tons of cargo on future missions to the moon and Mars. A first orbital Starship flight is planned for year's end.
(Reporting by Hyunjoo Jin in Berkeley, California, Raphael Satter in Washington and Munsif Vengattil in Bengaluru; Additional reporting by Susan Heavey in Washington; Writing by Peter Henderson; Editing by Will Dunham)
By Hyunjoo Jin, Raphael Satter and Munsif Vengattil