The US space agency hailed the decision as another step toward ending America's reliance on Russian vehicles for access to low-Earth orbit.
Nasa, which has been unable to send astronauts to space since the retirement of the space shuttle in 2011, awarded a total of $6.8 billion to the two companies for their respective spacecraft.
"The total potential contract value is $4.2 billion for Boeing and $2.6 billion for SpaceX," Nasa administrator Charles Bolden said.
"It was not an easy choice, but it is the best choice for Nasa and the nation."
Each company must show it can successfully complete a test flight with one astronaut aboard before moving on to between two and six more flights contracted with Nasa to deliver astronauts to and from the space station. No date for those missions has been set.
The spacecraft will launch from Cape Canaveral in Florida, where the space shuttle so often blasted into the skies over the past decades.
With the end of the 30-year space shuttle program in 2011, the world's space powers have had to rely on Russia's Soyuz for transporting rocket scientists to the orbiting outpost, at a cost of $70 million per seat.
"From day one, the (President Barack) Obama administration has made it clear that the greatest nation on Earth should not be dependent on other nations to get into space," Bolden said.
"Thanks to the leadership of President Obama and the hard work of our Nasa and industry teams, today we are one step closer to launching our astronauts from US soil on American spacecraft and ending the nation's sole reliance on Russia by 2017."
About the spacecraft
Boeing has received the largest amount of Nasa funds $620.8 million not including Tuesday's award to help build its commercial crew vehicle, according to Nasa.
Boeing's acorn-shaped space capsule is called the Crew Space Transportation-100, or CST-100 for short, and designed to carry up to seven passengers or a mix of crew and cargo to the space station, which circles the planet in low-Earth orbit.
The sleek, metallic spaceship is designed without welding creases, may be reused up to 10 times, and is equipped with wireless Internet access and tablet technology so the crew can interface with mission control.
"The CST-100 offers Nasa the most cost-effective, safe, innovative and proven successor to the space shuttle," said John Elbon, Boeing vice president and general manager, space exploration.
California-based SpaceX has already been awarded $554.5 million to develop its crew vehicle, which it has based on the Dragon cargo carrier it designed and which in 2010 became the first private spaceship to complete an unmanned resupply mission to the ISS.
Musk unveiled the Dragon Version Two, or V2, at a glitzy night-time news conference in May.
Shaped like a gum drop and painted gleaming white with blue accents, the Dragon V2 is designed to be able to "land propulsively almost anywhere on Earth," and could carry up to seven crew members.
"SpaceX is deeply honored by the trust Nasa has placed in us," Musk said in a statement.
"It is a vital step in a journey that will ultimately take us to the stars and make humanity a multi-planet species."
Sierra Nevada lost out on its bid for more Nasa cash, having received $363.1 million in Nasa seed money for its Dream Chaser vehicle, which looks like a miniature space shuttle.
Nasa declined to say why Boeing and SpaceX were chosen over Sierra Nevada.
The selection of the two companies was designed to encourage competition in the fledgling field of commercial crew space transport, experts said.
"Today's announcement from Nasa marks an important milestone for our nation's space program and is an exciting development for Florida and the commercial space industry," said Florida Senator Marco Rubio.