Last week, things were looking pretty bleak for the planet-hunting Kepler Space Telescope when it unexpectedly went into 'emergency mode' (EM) just before its latest campaign was due to start. NASA scientists promptly declared a 'state of emergency' and diverted all ground communications towards rescuing the mission.

But the Kepler team has just made everyone's week by announcing that they've managed to recover the spacecraft from EM and get it back online again - and will hopefully have it back in 'science mode' soon.

NASA scientists still aren't quite sure what happened - they're waiting for Kepler's data from the past couple of weeks to be downloaded before they can piece together what went wrong - but in the meantime, everyone's feeling pretty relieved about the telescope's fate.

"On Sunday morning, the spacecraft reached a stable state with the communication antenna pointed toward Earth, enabling telemetry and historical event data to be downloaded to the ground," wrote mission manager Charlie Sobeck.

"The mission has cancelled the spacecraft emergency, returning the Deep Space Network ground communications to normal scheduling."

It was a long weekend for Kepler and the team, but the spacecraft has been recovered! :)https://t.co/D0Y2uTGP3K pic.twitter.com/Jaek5HZGTH — NASA Kepler and K2 (@NASAKepler) April 11, 2016

Prior to going into emergency mode, Kepler was taking a much-needed break in 'point rest state', which basically means the telescope was between campaigns and was operating in a fuel-efficient mode with its antenna pointed towards Earth so it could await further instructions.

But less than 14 hours before NASA was due to start the next campaign, the spacecraft put itself in EM, which meant it was burning through a huge amount of fuel, and was in its "lowest operational mode" - effectively drifting through space around 120 million km (75 million miles) away.

After working through the weekend, the team has now been able to bring it back online, and will spend the next week testing all on-board systems to make sure Kepler is healthy enough to get back to what they call 'science mode' (our favourite mode).

But although they want to take their time making sure the spacecraft is working properly again, they're also on a pretty tight deadline. The next phase of Kepler's K2 mission is to observe the stars at the centre of our Milky Way for any unusual planets or objects, and that observing window ends on July 1, when the galactic centre will move out of Kepler's vantage point. So they need to act relatively quickly.

In the meantime, ground based observatories are already fixated on the region, and will continue to monitor what's going on, while waiting for Kepler to join the party.

Kepler has had an incredibly successful career, detecting almost 5,000 suspected exoplanets, including the most Earth-like exoplanet to date, and discovering the first ever shockwave coming off a supernova, as well as a strange megastructure orbiting a distant star.

Although the telescope has overcome other problems during its seven years in space - it was once declared unfixable by NASA after its wheels stopped working - this is the first time it's ever gone into emergency mode.

But Kepler has a dedicated team behind it monitoring it around the clock and making sure it stays online, and it's also got a pretty strong public fan base too, who aren't ready to let it go quiet any time soon.

"It was the quick response and determination of the engineers throughout the weekend that led to the recovery," wrote Sobeck. "We are deeply appreciative of their efforts, and for the outpouring of support from the mission's fans and followers from around the world."

It's good to have you back, Kepler.