A 20-story unmanned Titan IV rocket, designed to replace the manned shuttle as the military space workhorse, thundered into orbit early yesterday, carrying a secret cargo and providing a long-needed lift for the troubled booster program.

"It was a beautiful sight to behold," said Air Force Col. Frank Stirling, Titan program director.

"We are well on our way to achieving the full capability that this nation needs to continue our access to space."

The classified flight, which lifted off at 1:22 a.m. from Cape Canaveral Air Force Station, was not announced in advance, and the payload was not revealed.

Independent analysts believe it to be an electronic eavesdropping satellite or a missile-warning sentry.

This was the second launch of the country's most powerful unmanned rocket; two more launches reportedly are planned in 1990.

The first $250 million Titan IV was launched a year ago, carrying what was said to be a missile-warning satellite. That flight had been delayed almost a year and even then came close to catastrophe when an engine nozzle malfunctioned.

Grounded since then, the rocket has sometimes been described by critics as a "hangar queen," falling far short of the 10 flights the Air Force originally had planned by the end of 1990.

And last month, the General Accounting Office, investigative arm of Congress, said the Air Force and the rocket maker, Martin Marietta Corp., had mismanaged the program, adding more than $207 million in cost overruns. The Air Force has since increased the number of people monitoring the contract.

In March, a commercial Titan III rocket also made by Martin Marietta deposited a $150 million Intelsat satellite into a uselessly low orbit because of a mix-up in its wiring.

The Titan program has been expanded "despite tremendous pressure on our schedule" and on the personnel, said Martin C. Faga, assistant secretary of the Air Force for space.

In the mid-1980s, Air Force officials had resisted government policy of flying all military and other space cargo on the shuttle, initiating a limited Titan IV program as a backup. After the Challenger exploded in 1986, the Air Force began to shift to near-total reliance on the Titan IVs, which use both solid and liquid propellants and can carry almost as much payload as the shuttles.

"The military has put all its eggs in a different basket," said space policy analyst John Logsdon of George Washington University. "But it's equally in one basket. I think they {Air Force officials} wanted a system they could control, in addition to wanting to avoid the inherent problems of the shuttle."

The Defense Department has a $7.1 billion contract with Martin Marietta for four Titan IVs, with an option for eight more, and hopes to buy 75 by the end of 1997, Stirling said. That would put total program cost at $17 billion, he said.