TOKYO -- Japan's Hayabusa2 spacecraft departed from a distant asteroid on Wednesday, starting its yearlong journey home after successfully completing its mission to bring back soil samples and data that could provide clues to the origins of the solar system, the country's space agency said.

The Japan Aerospace Exploration Agency said the spacecraft left its orbit around the asteroid Ryugu, about 300 million kilometres (180 million miles) from Earth.

Hayabusa2 on Wednesday captured and transmitted to Earth one of its final images of Ryugu, or "Dragon Palace," named after a sea-bottom castle in a Japanese folk tale, as it slowly began moving away from its temporary home, JAXA said. Hayabusa2 will continue its "farewell filming" of the asteroid for a few more days.

Then Hayabusa2 will adjust its position on around Nov. 18 after retreating 65 kilometres (40 miles) from the asteroid and out of its the gravitational pull. It will then receive a signal from JAXA to ignite a main engine in early December en route to the Earth's vicinity.

Hayabusa2 made touchdowns on the asteroid twice, despite difficulties caused by Ryugu's extremely rocky surface, and successfully collected data and samples during its 1 1/2-year mission since arriving there in June 2018.

In the first touchdown in February, it collected surface dust samples. In July, it collected underground samples for the first time in space history after landing in a crater it had earlier created by blasting the asteroid surface.

Hayabusa2 is expected to return to Earth in late 2020 and drop a capsule containing the precious samples in the Australian desert.

It took the spacecraft 3 1/2 years to arrive at the asteroid, but the journey home is much shorter thanks to the current locations of Ryugu and Earth.

JAXA scientists believe the underground samples contain valuable data unaffected by space radiation and other environmental factors that could tell more about the origin of the solar system 4.6 billion years ago.

Asteroids, which orbit the sun but are much smaller than planets, are among the oldest objects in the solar system and may help explain how Earth evolved. Hayabusa2 scientists also said they believe the samples contain carbon and organic matter and hope they could explain how they are related to Earth.