Here's the basic outline from ... The Buried Age:
22 years later, she was ambushed by a Ferengi vessel, which got a lucky shot and severely damaged the ship. Picard used the 'Picard Manuever' to fool the Ferengi and destroyed them (also a lucky shot), but the Stargazer's damage was too severe. IIRC, the autodestruct had been disabled, so they set the Stargazer to plunge into a gas giant and abandoned ship. By a total fluke, the Stargazer's course slungshot it into orbit instead of being pulled in by the planet's gravity, and DaiMon Bok found it when investigating the incident.
Close, but just to clarify:
They never made a stable orbit around the giant planet to begin with, since they were knocked out of warp in its proximity by the attack, so its orbit was decaying to begin with. And they abandoned ship because of the fires onboard, with their intention being to vent atmosphere to smother the fires and then return, but there was too much damage and a radiation leak, so return was impossible. And instead of a slingshot into orbit, the ship sort of "skipped" off the upper atmosphere like a stone skipping on water (something that does really happen with meteoroids sometimes), temporarily delaying its fall into the Jovian; it would've fallen in for good if the Ferengi hadn't shown up at just the right time.
I don't mind telling you, it took a lot of thought to figure out a reason why they'd abandon a ship and believe it to have been destroyed when it actually wasn't. There's a lot about "The Battle" that was a struggle to make sense of.