U.S. President Donald Trump has signed into law a bill that increases the budget of the National Aeronautics and Space Administration (NASA), maintains the agency's earth science program and adds human exploration of Mars as a goal.

Trump said the law will reinforce NASA's core mission of human space exploration while continuing to transition activities to private aerospace companies. "I hope they will pay us a lot of money," Trump said in an Oval Office signing ceremony attended by a bipartisan group of lawmakers.

The measure also directs the agency to develop programs to get a "crewed mission to Mars in the 2030's" and explore the "potential for human habitation on another celestial body" in the 21st century.

A manned mission to Mars had been widely viewed as NASA's next great challenge. The agency is expected to develop new technology to achieve the mission by relying heavily on private aviation companies.

SpaceX, owned by Elon Musk, is scheduled to launch an unmanned spaceship to Mars as soon as 2018.