Media playback is unsupported on your device Media caption The private space company SpaceX has successfully landed a rocket on a barge floating off the Florida coast

The US aerospace company SpaceX has successfully landed a resusable rocket on an ocean platform, after four previous attempts failed.

Mission controllers cheered as the Falcon 9 rocket remained upright on the platform off Florida.

It was returning from delivering an inflatable habitat into space for Nasa.

The inflatable room will attach to the International Space Station (ISS) for a two-year test and become the first such habitat for humans in orbit.

It is due to reach the ISS around 09:00 GMT on Sunday along with other freight aboard the Dragon capsule.

Built by Nevada company Bigelow Aerospace, the habitat is intended to pave the way towards the use of such rooms for long space trips, including to Mars.

'Really excited'

Nasa had not attempted a cargo run with SpaceX since a June 2015 mishap, when an unmanned cargo rocket exploded soon after take-off.

The Falcon 9 lifted off on schedule at 16:43 local time (20:43 GMT) on Friday from Cape Canaveral Air Force Station in Florida.

Media playback is unsupported on your device Media caption BBC Newsround profiles the inflatable module

After propelling the Dragon capsule into the upper atmosphere, the main-stage booster of SpaceX's Falcon 9 rocket separated and landed on the floating platform, known as a drone ship.

"The rocket landed instead of putting a hole in the ship - or tipping over - so we're really excited about that," SpaceX founder and chief executive Elon Musk told reporters in Florida.

At the company's mission control centre in Hawthorne, California, employees cheered wildly, jumping up and down and chanting "USA, USA, USA!"

SpaceX is seeking to kick off a new era of reusable rockets and affordable private space travel.

Bigelow Aerospace, the project of real estate billionaire Robert Bigelow, launched prototype expandable habitats before but none have been occupied by humans.

This 1,400kg contraption, once attached and inflated in about a month's time, will be visited periodically by ISS personnel.

Made of many layers of fabric and covered with a flexible Kevlar-like material, the Beam will be tested to see how well it stands up to fluctuating temperatures and high levels of radiation.