British forces in the Falklands opened a major ground attack yesterday on the capital of Stanley, Argentina's heavily defended final stronghold on the islands, and advanced several miles in bitter combat.

Thousands of Marine commandos and paratroopers assaulted Argentine positions west of Stanley before dawn. Argentine military officials said the attack followed an overnight naval bombardment and appeared to be the start of Britain's long-awaited drive to complete its recapture of the islands.

British Defense Secretary John Nott told a news conference in London that the attack had surprised the Argentines: "The enemy, who were largely asleep at the time, first knew of the attack when our infantry appeared among them." He said that the British had moved forward by up to five miles by dawn and that they had taken "all objectives" in "hard fighting."

"We now control some very important tactical high ground," a British Defense Ministry source said, adding that the Argentines were expected to counterattack. Other British sources said several hundred Argentines apparently had been taken prisoner, while Nott said initial British casualties were light.

In Buenos Aires, a military spokesman said that the British had advanced only two miles before being halted by stiff resistance. He said fighting was continuing for the hills between Stanley and Britain's previous front line to the west, which ran along a ridge of higher hills including Mount Kent.

A British defense spokesman said British troops were within six miles of the center of Stanley, while Argentine press reports have indicated that the defenders' main line of trenches and artillery batteries is 2 1/2 to 3 1/2 miles outside the capital.

The Argentine joint chiefs of staff said Argentine planes had attacked a British frigate that was bombarding Stanley, set the ship afire and forced the crew to abandon it. British officials said they did not know of a frigate being hit.

Fighter-bombers and helicopter gunships from both sides reportedly were strafing and bombing enemy positions, although poor weather apparently was hampering air activity. Unofficial reports in Buenos Aires late last night said that one British Sea Harrier jet had been shot down and another damaged.

The fight for Stanley is expected to be the decisive battle of the war. Argentina has concentrated the bulk of its ground forces, estimated at 7,000 troops, in the capital and waited for the British to come and try to take it.

Britain has landed about 9,000 troops on East Falkland Island since establishing a beachhead on its western coast on May 21. Its forces have driven steadily eastward toward Stanley and have surrounded it.

Argentina still has two small contingents of troops on West Falkland Island, at Point Howard and Fox Bay, but Britain is expected to clear them out easily if Stanley is taken.

In Washington, national security adviser William P. Clark briefed President Reagan by telephone on the new fighting, a White House spokesman said. Reagan was resting at the Camp David presidential retreat after his tour of Europe.

Argentina was the first to announce the British attack, interrupting live television broadcasts of a mass celebrated by Pope John Paul II before more than a million persons in a Buenos Aires district.

In the culminating event of a 32-hour visit to Argentina, the pope did not specifically mention the new fighting but urged the crowd to "make a chain of union, stronger than the chains of war." The crowd chanted in response: "We want peace; we want peace."

The pope hastily arranged his trip to Argentina to demonstrate evenhandedness after visiting Britain two weeks ago on a trip that had been scheduled long before the Falklands conflict erupted. In a series of messages delivered in Buenos Aires, he urged both sides to quickly seek a diplomatic solution.

Argentine President Leopoldo Galtieri, who traveled to Buenos Aires' Ezeiza Airport to bid farewell to the pope this afternoon, stood silently while the pontiff called for peace in the South Atlantic. The general then rushed to a hurriedly called meeting of the military junta at the military command headquarters.

Galtieri later went to the presidential palace to follow war reports late into the night, a spokesman said.

Argentina, which has claimed the Falklands since losing them to a British attack in 1833, surprised London and the world by invading the islands April 2.

Galtieri said he had never expected the British to put up much of a fight. British opinion was aroused by Argentina's aggression, however, and Prime Minister Margaret Thatcher ordered a task force to the South Atlantic. Seven weeks of diplomacy--including a lengthy diplomatic shuttle by Secretary of State Alexander M. Haig Jr.--failed to prevent the British counterinvasion.

The British were not saying what happened during the day yesterday after they claimed to have taken by dawn all the ground they intended. Sources, however, suggested that many of the British troops would be digging in and consolidating their positions against Argentine counterattack. Others were believed to be probing the outskirts of Stanley between the defensive perimeter overrun by the British and the next concentration of Argentine troops at the former British Marine barracks at Moody Brook on the edge of the capital. The Argentine news agency Telam said fighting already had started at Moody Brook.

Argentina's troops at Stanley are aligned in a horseshoe arrangement around the town, dug into shoulder-high trenches and bunkers and supplied with heavy machine guns, rockets and artillery. Military sources in Buenos Aires have said recently that some Argentine troops had moved into vacant houses in the town, whose population is said to have shrunk from 1,100 to fewer than 200.

An Argentine communique charged that the bombardment of Stanley by British ships had been "indiscriminate" and that two island residents had been killed and four injured when shells struck their homes.

The military command later identified the dead as Susan Whitley, 30, a British citizen, and Doreen Bower, 46, who holds Falklands citizenship.

Saying that previous naval bombardments had not struck homes in Stanley, the military command charged that British gunners deliberately had aimed at civilian targets in "a lack of respect for human rights." In contrast, the communique said, Argentine forces "have acted at every moment with a maximum of restraint and humanity, as was proven when they took the islands without causing casualties among the English forces or the inhabitants."

The British Defense Ministry said it had no information on another incident, reported by Argentina Friday, in which a British jet allegedly fired two missiles at the Argentine hospital ship Bahia Paraiso docked in the port of Stanley.

The British government is now controlling information about the fighting more tightly than ever. Defense Secretary Nott announced the British attack four hours after the initial Argentine reports and disclosed only what he and defense staff chief Admiral Sir Terence Lewin thought best to make public. Almost everybody in the Defense Ministry is being kept in the dark about the battle at the request of the British commanders on the Falklands, according to ministry sources.

The Defense Ministry continued to give no details on casualties suffered by British soldiers and sailors in Argentine air attacks on landing ships Tuesday, saying the information would help the enemy. The Associated Press quoted senior British officials as saying the toll was 60 dead and 120 wounded.

About 1,000 Argentine soldiers taken prisoner by British forces in earlier fighting left Montevideo, Uruguay, to return home in a ferry boat requisitioned by the Argentine Navy. A British support ship had brought the Argentines to Uruguay.