To the rockets' red, white and blue glare, to the brassy bombast of "Yankee Doodle" and the "Battle Hymn of the Republic," to the shouts, whistles and tears of millions of spectators, the Statue of Liberty was welcomed noisily into her second century tonight.

Tonight's 10-ton, 40,000-shell fireworks shower was set to music and broadcast to 40 countries. President Reagan and a host of other dignitaries watched from the aircraft carrier USS John F. Kennedy as the pyrotechnics exploded from a necklace of 30 barges strung around the shores of lower Manhattan and Liberty Island.

Incandescent rainbows, splinters of gold and silver, sizzling stars of light reflected off the windows of Wall Street skyscrapers. The half-hour show, with displays from the United States, Australia, Canada, West Germany, France, Great Britain, Hong Kong, Italy and Japan, followed the Boston Pops Americana concert in Liberty Park and culminated a day of extraordinary pageantry.

In the morning, gliding through sunlit waves, tall ships from across the world sailed in procession through the harbor, in a salute to the 100th anniversary of the refurbished statue's arrival from France as a gift to the American people.

Exuberant celebrants, toting binoculars and cameras, thronged the shores of Manhattan, Brooklyn, Staten Island and New Jersey to catch a glimpse of the majestic vessels, their sails billowing in the wind, their crews manning the yards high over the harbor.

Besides the 22 full-rigged tall ships, redolent of history and legend, the 18-mile parade included 250 sailing vessels from 30 nations. Sleek schooners, graceful sloops, elegant yachts, a chunky Chinese junk with electric blue sails and a jaunty French catamaran with Lady Liberty's portrait on her mainsail.

In a Governors Island ceremony with French President Francois Mitterrand and 3,000 dignitaries, diplomats and journalists, Reagan said, "Perhaps, indeed, these vessels embody our conception of liberty itself -- to have before one no impediments, only open spaces to chart one's own course, to take the adventure of life as it comes, to be as free as the wind, as free as the tall ships themselves."

With the statue gleaming behind him, Reagan added that it was "fitting, then, that this procession should take place in honor of Lady Liberty and, as the wind swells the sails, so too may our hearts swell with pride with all that liberty's sons and daughters have accomplished in this, the land of the free."

In the distance bobbed a populist armada of pleasure boats, from the mammoth ocean liner Queen Elizabeth 2, packed with 800 Chrysler dealers and their families, to beer-sloshed cabin cruisers, motorized rubber rafts, yachts, gaily painted tugs, several kayaks, plucky little sailing vessels of every description and the Staten Island ferry, jammed with several hundred city employes and politicians, including Mayor Edward I. Koch.

While Coast Guard officials feared "boat-lock," the mood of the harbor was of one of jubilant if sun-burnt revelry, as blimps glided overhead, helicopters zoomed about, the Air Force Blue Angels flew their jets overhead and a fresh breeze jostled the waters.

As Reagan put it, "This weekend we celebrate, my friends. We cut loose."

Even the honking horns of passing ships drowning out official speeches could not dampen the relaxed humor of the ceremonies.

"What a glorious Fourth of July!" declared Chrysler Chairman Lee A. Iacocca, chief fund-raiser for the statue's renovation, to applause. "One thing America knows how to do is throw a party."

Military bands, decked out in spanking uniforms with gold braid, tasseled hats and spit-shined shoes, trumpeted their brass toward the sun. The flags of the 50 states were waved aloft by fresh-faced cadets. Identical French and American stamps, commemorating France's gift, were presented to Reagan and Mitterrand.

Yuri Dubinin, the new Soviet ambassador, decked out in his wife's rumpled khaki hat and sporting a brightly striped shirt, was clearly enjoying himself. "We have every respect for the celebration as a national holiday of the United States," he said. "It's a very good statue, a very good statue."

Other communist ambassadors, smiling blandly through the patriotic paeans to liberty, were circumspect. "Freedom has a deeper meaning -- freedom from hunger," said Miroslav Houstecky, the Czechoslovak envoy.

As a huge blimp inscribed "Fugitape: official videotape of major league baseball" wafted by, Zhang Zai, the Chinese charge d'affaires, remarked, "Of course, everyone has his own definition of liberty."

From elsewhere in the country, the Associated Press reported that the USS Constitution took its annual lap around Boston Harbor, firing a salute that was answered by the bells of Old North Church.

In Rockland, Maine, a fleet of windjammers dating from the 1800s competed in the ninth annual Great Schooner Race. In Gatlinburg, Tenn., which makes a point of having the first parade each year, a U.S. Navy band and a Statue of Liberty float stepped off at one minute after midnight.

Baker, Miss., was one of several towns doing without fireworks this year for lack of insurance. Fireworks were blamed for injuries in Dunwoody, Ga., when a rocket veered into a crowd of about 40,000 people in a shopping mall parking lot, and in Sioux Falls, Iowa, where four children were burned in an explosion in a garage. A Washington state teen-ager was shot in the head after he and his companions blew up a mailbox with a firecracker.

Around the country, accidents with fireworks killed twp persons and injured more than three dozen others, including 30 who suffered minor burns and cuts when a rocket went astray and sailed into the stands at a show in a Newark, N.J., stadium.

In Salt Lake City, 100 buses carried 3,000 barbershop quartets to Cougar Stadium to perform in a liberty tribute with the Mormon Tabernacle Choir. Windham, Conn., residents could not muster enough live music to mount a parade, so 1,500 people turned out to march with transistor "boomboxes" tuned to a local radio station broadcasting parade music.

On Governors Island, 174 members of the diplomatic corps arrived from Washington by chartered plane for the tall ships parade.

Many of the men wore blue baseball caps inscribed "Liberty Weekend," and several women carried parasols. Sen. Robert J. Dole (R-Kan.), Sen. Daniel Patrick Moynihan (D-N.Y.), Secretary of State George P. Shultz, Interior Secretary Donald Hodel and Transportation Secretary Elizabeth Hanford Dole were also on hand.

Earlier in the day, Reagan boarded the refurbished battleship USS Iowa for an International Naval Review of 31 destroyers, frigates, submarines, battleships and aircraft carriers from the United States and 14 foreign countries.

As the hulking gray Iowa slid past the visiting vessels, each sounded a 21-gun salute.

Overhead, Navy aircraft roared by in neat formations. A Navy skywriting team posted American flags in the sky, with the legend "U.S. Navy salutes the ships of world."

"It was absolutely brilliant," Reagan said. "There are no words to describe my pride."

Announced by two fireboats pumping jets of red, white and blue water into the air, the parade of sailing ships was led by the 295-foot Coast Guard training vessel Eagle, the United States' most famous tall ship, with a mast height of 147 feet and a golden eagle as her figurehead.

As each boat passed between the Statue of Liberty and the island viewing stand, daytime fireworks exploded in the national colors of the ship's home nation. Tiny parachutes exploded, releasing flags overhead.

The names of the exotic vessels from nations as distant as Oman, Indonesia and Argentina, evoked the centuries-old lore of the sea. Aboard Italy's Amerigo Vespucci, an 18th century replica, more than 100 sailors poised high in the rigging and raised their arms, crying "Viva!" in a salute to the statue.

The three-masted 270-foot Simon Bolivar from Venezuela, in full dress with pennants flying, sported sails with the image of Lady Liberty and the message "Signs of Liberty."

Most dramatically, from the three-masted Gloria from Colombia, a deep chorus of sailor's voices carried across the water in a lusty anthem to Cartagena, their nation's naval academy.

"It's magnificent!" declared Swedish Ambassador Count Wilhelm Wachmeister, dressed in a blue tie with red and white stars. "For people all around the world, the heart beats faster when you see the Statue of Liberty -- like your heart beats faster when you see a beautiful woman."

Also watching from Governors Island, scientist Albert Sabin, 79, inventor of the polio vaccine, recalled his first glimpse of the statue as an immigrant from the Soviet Union in 1921.

"We came through Ellis Island," he said. "We came on steerage. We were poor. I saw the statue, and I thought about the wonderful future that might lie before me."