(covers information from several alternate timelines)
According to Data, the vortex was similar to the Enterprise's tractor beam, only much more powerful. Counselor Troi was able to sense an instinctual intelligence in the vortex, which was attempting to learn more about the Enterprise. As the Enterprise was being pulled in, Captain Picard ordered full warp power in an attempt to escape, but the effort proved futile. As the ship was pulled in, Picard was attacked by an energy beam from the vortex, and Troi realized that the intelligence in the vortex recognized the Enterprise as an entity with Picard as its brain. In order to protect the ship, Picard decided to leave in a shuttlecraft, hoping that the vortex would focus its attention on him, allowing the Enterprise to escape. The plan failed, however, and the Enterprise was destroyed. After witnessing this, Picard and his shuttle were thrown back in time six hours.
Six hours in the past, the Enterprise encountered the shuttle, with an unconscious Picard inside. Doctor Pulaski was able to determine that, as a result of Picard being thrown back in time, all of his body systems were out of phase, and as they approached the time from which he originally departed, they were slowly realigning. Examining the logs from the shuttle, the Enterprise crew learned about the ship's destruction in the vortex.
Eventually, the Enterprise encountered the vortex and was pulled in, at which point both Picard and his time-displaced counterpart were attacked by energy beams. Conversing with his counterpart, Picard learned why he originally left the ship, and that he was planning to do so again. Realizing that his counterpart was trapped in his previous pattern of behavior, and that for the Enterprise to be saved this cycle must be broken, Picard shot his counterpart with a phaser in order to prevent him from leaving the ship. Returning to the bridge, Picard ordered a course set for the exact center of the vortex, realizing that they were only wasting power attempting to escape. Accelerating into the vortex, the Enterprise was able to escape to normal space upon reaching the center. As this happened, history was changed, and both Picard's counterpart and the shuttle in which he arrived vanished. (TNG: "Time Squared")
According to both the Star Trek Encyclopedia (4th ed., vol. 1, p. 241) and the Star Trek: The Next Generation Companion (2nd ed., p. 82), it was originally intended that ""Time Squared" would segue into "Q Who" (142), in which the mischievous superalien is revealed as the cause of the vortex. The plan was scrapped at Gene Roddenberry's insistence, Hurley had said, and so adds confusion to the ending. 'Why would going into the vortex's center save you?' Hurley asked. 'It doesn't make sense. But it does if Q is pulling the strings.'"