The United States, sending three U.S. aircraft carriers and 27 warships in the Mediterranean toward Libya, plans to cross within the next two weeks "the line of death" Libyan leader Muammar Qaddafi has drawn across the Gulf of Sidra, administration officials said yesterday.

President Reagan has approved the ship movement, officials said, as a massive display of force that would only lead to shooting if Qaddafi fired first. Officials, who declined to be identified, said the action is not aimed at provoking Qaddafi into attacking U.S. ships or planes but acknowledged that detailed plans have been made to shoot back if that should happen.

The timing on when to cross the "line of death" has been left up to Vice Adm. Frank B. Kelso II, commander of the Sixth Fleet, who is in the Mediterranean aboard his flagship Coronado, the officials said.

The administration, the sources said, is simply exercising the United States' "right of navigation" in the Gulf of Sidra. On Jan. 25, Qaddafi threatened to attack any U.S. ship or plane that penetrated the elbow-shaped Gulf beyond 32 degrees 30 minutes north latitude, a line 150 miles from Libya out into the Gulf. The United States, as well as the Soviet Union and other maritime nations, recognizes Libyan territorial waters as extending only 12 miles from shore.

Navy officials acknowledged it was highly unusual, if not unprecedented, to concentrate three carriers off Libya. Officials said the U.S. plan calls for the carriers -- America, Coral Sea and Saratoga -- to sail near Qaddafi's "line of death" while their aircraft and heavily armed and more maneuverable escorts, including cruisers and destroyers, go past the line, into the Gulf.

The America entered the Mediterranean yesterday after crossing the Atlantic from Norfolk, but was still some distance from Libya. The Coral Sea was southeast of Sardinia off Italy yesterday while the Saratoga, which recently left the port of Palma on the Spanish island of Majorca in the Mediterranean, was headed east toward the Coral Sea.

The approximately 240 warplanes on the carriers include F14 and F18 fighters, armed with air-to-air missiles considered far superior to any armament in the Libyan air force; A6 and A7 bombers, and EA6B electronic warfare planes packed with eavesdropping gear to keep track of Libyan and Soviet military activities.

The Soviets have assigned their own intelligence-gathering ships to shadow each of the aircraft carriers, apparently to keep the Libyans informed of U.S. movements, officials said. They said the Soviet monitoring had made the current maneuvers something of an open secret, allowing them to discuss them.

The massing of U.S. ships and planes appears to be shaping up as the most significant attempt at gunboat diplomacy since Reagan took office five years ago. Planning for it began after the Joint Chiefs of Staff and other administration officials advised Reagan against bombing Libya to retaliate for its alleged connection with the terrorist attacks on the Rome and Vienna airports on Dec. 27.

The chiefs warned, the sources said, that they could not guarantee that bombing Libyan targets on a list prepared for Reagan would kill only terrorists linked to the airport attacks. Reagan decided against retaliatory bombing, but many of his advisers, particularly within the National Security Council, sources said, have been looking ever since for a way to give Qaddafi his comeuppance.

If Libyan planes try to stop U.S. fighters when they fly past Qaddafi's line, they will be heavily outgunned by the U.S. missile-firing jets. The mismatch has led some U.S. officials to speculate that Qaddafi, if he decided to respond, might order a nighttime attack on a U.S. ship by a seagoing commando force he has had trained.

The Soviets sent a submarine tender to Tripoli yesterday, apparently to serve as a relay post between Soviet ships in the Mediterranean and Libyan officials ashore. The Soviets have eight combat ships at anchor off Tunisia in easy reach of Libya, officials said.