U.S. Brig. Gen. James L. Dozier was rescued unharmed today by a special squad of Italian police that stormed a second-floor apartment in Padua where the officer was being held by the Red Brigades terrorists who had kidnaped him 42 days ago.

Dozier later was quoted as saying that, as the police broke in, one of the five terrorists was leveling a gun at his head. Police said Dozier was found blindfolded, bound, his ears stuffed with wax, lying in a tent set up in the living room of the apartment.

The 50-year-old general, his usual crew cut grown out and with full blondish-gray beard, was wearing a blue track suit and appeared to be in good health when he left the apartment accompanied by police and beaming U. S. military officers.

Police and spectators broke into applause when Dozier came out of the building. "Sto bene (I'm fine)," he told an Italian television reporter before being taken away in a car to the police headquarters in Padua where he asked for a cappuccino and telephoned his wife, Judith, who at the time of the rescue was in West Germany with their daughter, Cheryl.

President Reagan, who was awakened at 6:50 a.m. and told about Dozier's rescue, spoke to the general by telephone. He later spoke at a luncheon where he said Dozier "sounded as if he had just gone around the corner for five minutes." The president went on to say, "His country and our allies can be very proud of this gallant man."

The raid on the apartment above a supermarket in a residential area of Padua was carried out by 10 members of an elite unit of the Interior Ministry's antiterrorist force, formally called the Special Agents for Security Operations. They are given training in hand-to-hand combat and in the use of such weapons as bazookas.

This morning, when the signal to attack was given, the team broke into the apartment and overcame the five terrorists, three men and two women, without firing a shot.

It was the first time that Italian police have succeeded in locating and freeing a prisoner of the Red Brigades. During the past decade the terrorist band has carried out eight political kidnapings, killing three of its victims--including, in 1978, former Italian premier Aldo Moro. The brigades have declared their intention to assault the foundations of the Italian government, through assassinations and acts of terrorism, with the hope of making it collapse so it can be replaced by a Marxist system.

For much of their existence the brigades' war has been confined to the Italian state and its symbols: police, politicians, business executives and even journalists. This was the first time they trained their sights on NATO and the United States. Their propaganda releases described Dozier as "a pig, an executioner, a hero of the American massacres in Vietnam," and claimed he was in Italy "to conduct repression and promote unemployment."

Padua Police Chief Gianfranco Corrias said later that the apartment had been under surveillance for three days following a tip that Dozier, chief of staff for logistics and administration for NATO's southern command, was being held there. Padua, an ancient university town on Italy's Adriatic coast, is about 46 miles east of the Verona NATO base where Dozier was kidnaped Dec. 17.

Police sources said tonight that five pistols, 15 submachine guns, seven hand grenades, six packets of plastic explosive, and ammunition of various types had been found in the apartment along with about $16,000 in Italian currency, several typewriters, a mimeographing machine, false identity cards and file cards with information about prominent personalities in the Veneto region.

According to a spokesman at Padua police headquarters, the first thing Dozier said when police freed him was "E' meraviglioso! It's marvelous! ." The spokesman said that at first the much-decorated Florida-born officer had appeared to be somewhat in shock, speaking in a mixture of Italian and English. "He asked what day it was and then kept repeating, 'Giovedi, Giovedi' Thursday, Thursday ," the spokesman said.

Later in Rome, after speaking with Dozier by phone, U.S. Ambassador Maxwell Rabb told reporters that the general told him that when police burst into the apartment his captors were about to murder him.

"When the rescuers came in, a gun was pointed at me and I didn't know whether it would go off," Dozier reportedly told the ambassador. "You can imagine how good I felt when the Italian police took me out," he was quoted as saying.

Adm. William Crowe, commander of the NATO base in Naples and the highest ranking U.S. officer in Italy, said he spoke with Dozier by phone and that the general was well, although a bit tired. "During my imprisonment, I never gave up hope of being freed," Dozier is said to have told Crowe, adding, "Now I'm going to get a haircut".

A few hours after the rescue he was transferred to a U.S. medical facility at the giant American base in nearby Vicenza where he will undergo a series of medical tests.

News agencies reported that Dozier was reunited with his wife and daughter in the U.S. military hospital at Vicenze, where they had flown from West Germany. Before leaving Frankfurt, Mrs. Dozier read a brief statement, saying, "We want to say thanks to all the people in the world for their love and their prayers which worked in his favor."

Dozier, a West Point graduate and a veteran of Vietnam, was the highest ranking American officer at the smaller Verona NATO base and the third highest ranking American officer in Italy when he was abducted.

About 5:30 p.m. Dec. 17 the general was taken by force from his apartment in Verona by four men disguised as plumbers. He was knocked unconscious and carried away in a large trunk while his wife was left tied and gagged in the bathroom.

Today's operation was described as extremely delicate by Police Chief Corrias. He explained that the 10 special agents had to be coordinated ith other police.

The agents, for the most part long-haired youths wearing bullet-proof vests under or over civilian clothes and who later donned masks to hide their identities from the TV cameras, were the spearhead of the intervention force. Stationed throughout the immediate area were other police whose mission was to keep passersby and shoppers out of harm's way.

Surrounding the whole area was a ring of police cars that sought to isolate the zone completely.

Police sources said they found in the apartment the typewriter used to write the five communiques released by the Red Brigades during Dozier's captivity and the trunk that had been used to carry him out there.

On the wall in the living room where Dozier's tent had been pitched was a sheet bearing the five-pointed Red Brigades' star with which he had been posed in the two photographs that the terrorists released. Police said the Red Brigades had adopted the practice of putting their kidnap victims inside tents so that if they are released they are unable to describe their physical surroundings.

The apartment had been rented by a Padua doctor, apparently for his 21-year-old daughter, Emanuela Frasella, who was one of those arrested and who reportedly served as the band's contact with the outside world, doing all the necessary grocery shopping.

The others were said to include Antonio Savasta, 27, and his girlfriend, Emilia Libera, 28. Police said they also believed that veteran terrorist Barbara Balzarani, charged with playing a key role in the Moro kidnaping, may have played an important role in organizing the seizure of Dozier.

Since Dozier's abduction, Italian antiterrorist police and paramilitary carabinieri, assisted by several American antiterrorist experts, have combed much of northern Italy looking for the general and his captors.

In the process, in four separate operations, they captured more than 20 other terrorists, including Giovanni Senzani, who was described as a theoretician for the movement, and discovered many hideouts and arms caches.

But until this week it did not appear that there had been any breakthroughs. The announcement that there had been a tipoff led to speculation that money supposedly offered by unspecified "friends of Gen. Dozier" might have encouraged someone to talk.

Several weeks ago an Italian official in Verona confirmed that there was such a fund, suggested the "friends" might be Italian, and said a phone number would be published for those wanting to offer information leading to the general's release. That number, however, was never published, a U.S. Embassy official said today.

The news of the rescue, considered a major blow to the seemingly invincible Red Brigades, caused police officials and political figures to exult. "We did it!" exclaimed Interior Minister Virginio Rognoni, who heads the police.

Ambassador Rabb, who got the news of Dozier's release while conferring with Italy's defense minister, Lelio Lagorio, said the two men jumped up in delight and embraced.

Applause broke out in the Italian parliament when the rescue was announced. Congratulatory telegrams from foreign leaders like Chancellor Helmut Schmidt of West Germany and from Italian leaders like Communist Party head Enrico Berlinguer began pouring onto the desk of Prime Minister Giovanni Spadolini.

It was President Sandro Pertini who summed up the general feeling when he exclaimed, "Bravi! Bravissimi!" (Good work! Excellent work!)