The Hubble space telescope is close to resuming full operations after Nasa “jiggled it around”.

The telescope was sidelined earlier this month after a gyroscope failed, leaving it unable to point in the right direction during observations.

The device had been expected to fail at some point this year, but the surprise came when a backup did not kick in properly after the initial failure. As a result, Hubble has remained in so-called safe mode and all science observations are on hold.

Gyroscopes are needed to keep Hubble pointing in the right direction as it operates 340 miles (545km) above Earth. Precise pointing is crucial: astronomers use the telescope to peer deep into the cosmos, revealing faraway galaxies, black holes and solar systems. Last week, astronomers said they may have discovered the first moon outside our solar system, with Hubble’s help.

The problem with the backup gyroscope was spotted when detectors in the gyroscope wrongly signalled that the wheel within the device was rotating at a much greater rate than that 19,200 revolutions per minute it should be spinning at.

Nasa has said Hubble is expected to return to normal science operations soon after it performed a “running restart” of the gyroscope on 16 October, which turned the device off for a second. The intention was to clear any faults that may have occurred during a restart on 6 October. That did not seem to work so it was followed up on 18 October with a series of spacecraft manoeuvres – known as turns – in an attempt to clear any blockage around the sealed “float” which contains the spinning wheel in the gyroscope. At the same time the system was switched between two modes to help with the procedure. The team think that the dodgy rotation speeds could have arisen if the float was off centre in the device.

“At a high level, if people want to call it jiggling around, I suppose they can,” Patrick Crouse, Hubble’s operations project manager, told the Washington Post. “But we were trying to do very particular activities we thought would clear the problem. It certainly wasn’t as simple as turning it off and turning it back on.”

The next day further jiggling of the telescope and twiddling of switches was performed: the issue now appears to be resolved.

The space agency said: “The Hubble operations team plans to execute a series of tests to evaluate the performance of the gyro under conditions similar to those encountered during routine science observations, including moving to targets, locking on to a target, and performing precision pointing. After these engineering tests have been completed, Hubble is expected to soon return to normal science operations.”

Jessie Christiansen at the Nasa Exoplanet Science Institute described the news as a “huge relief”.

“Hubble going down to one-gyro mode would in particular have hampered our efforts to characterise extrasolar planet atmospheres in the years running up to [the launch of the new space telescope] James Webb,” she told the website Gizmodo, which drew a comparison between the Nasa engineers’ efforts and the “turn it off and on again” approach familiar to anyone who has worked with or in IT.

The 28-year-old telescope has had trouble with its gyroscopes before. Shuttle astronauts replaced all six in 2009 during a spacewalk on the final servicing mission. Three of the devices are now considered unusable.