The
contract is worth $2.9 billion and is part of NASA's Artemis programme, which
aims to return astronauts to the moon by 2024 as a stepping stone to the first
human mission to Mars, DPA news agency reported.
SpaceX had
been competing against Amazon founder Jeff Bezos' private space company Blue
Origin and defence contractor Dynetics.
Musk tweeted "NASA Rules!!" in response to the
decision.
The SpaceX Starship, which is designed to land on the moon,
will include a spacious cabin and two airlocks for moonwalks, NASA said.
The goal is to eventually develop a fully reusable launch
and landing system that can be used for space travel to destinations including
the moon and Mars.
The mission will see four astronauts launched on NASA's
Orion spacecraft into lunar orbit, where two of them will transfer to the
SpaceX human landing system for their final journey to the moon.
The two astronauts will explore the lunar surface for around
a week before returning to Earth. They will be the first people to walk on the
moon for more than 50 years.
At least one of the two will be a woman. NASA also aims to
bring the first person of colour to the moon's surface as part of the Artemis
programme.
The US brought 12 astronauts to the moon between 1969 and
1972.