It is the kind of thing we see in sci-fi movies, an asteroid hurtling towards the earth and scientists coming together to save the planet from destruction.

However, this time it happened for real. For the first time in history, a NASA spaceship smashed into an asteroid seven million miles away to deflect its orbit. The only difference is that the asteroid in this case posed no danger and was not heading towards the Earth.

NASA let one of its spacecraft crash itself into a small asteroid to change its orbit on Tuesday. The asteroid, named "Dimorphos," was 1 million km (about 300 times the distance to the moon) away from the planet.

The collision was simply a technology demonstration to see if a similar feat could be accomplished successfully in the future. It is not yet known if they managed to achieve the desired results, writes The Mirror.

NASA shared a video showing the moment the unmanned spacecraft collided with the asteroid. "And we have an impact. A triumph for humanity in the name of planetary defence," a member of NASA's team could be heard saying in the video.

NASA had previously said: "Dart's target asteroid is not a threat to Earth but is the perfect testing ground to see if this method of asteroid deflection - known as the kinetic impactor technique - would be a viable way to protect our planet if an asteroid on a collision course with Earth were discovered in the future."

The asteroid has not been destroyed in the crash. It will instead slow down and change its orbit in the long term. The final results of the experiments will be discovered at a later date. The scientists will use the data from telescopes to track how the movement of Dimorphos has been affected.

NASA administrator Bill Nelson even likened the mission to the 1998 blockbuster "Armageddon." "We've all seen it on movies like 'Armageddon,' but the real-life stakes are high," he said in a pre-recorded clip released on social media.

Vesta Sizes Up
This composite image shows the comparative sizes of nine asteroids. NASA/JPL-Caltech/JAXA/ESA