The outlawed Irish Republican Army claimed responsibility today for a terrorist bombing here that killed at least three persons, injured 34 others and came close to killing Prime Minister Margaret Thatcher and her entire Cabinet.

The explosion ripped through the hotel and demolished the bathroom in Thatcher's first-floor suite just two minutes after she had used it.

The dead were Anthony Berry, 58, who was a member of Parliament, and two persons still to be identified. Fire officials said another person was missing in the rubble and presumed dead.

The blast occurred just before 3 this morning and tore a gaping hole through the top three floors of the elegant, seaside Grand Hotel next to the convention center here where the Conservative Party is holding its annual conference.

Among those most seriously injured are the chief Conservative whip in the House of Commons, John Wakeham, and Norman Tebbit, the minister for trade and industry, and his wife.

Although there have been attacks by the IRA and other Irish extremist groups on individuals and other targets before in Britain, this attack was unprecedented in its scope. Many members of Parliament said it was "miraculous" that Thatcher and members of her Cabinet were not killed.

The Provisional IRA statement, issued by its publicity bureau in Dublin about nine hours after the attack, contained a new warning.

Apparently referring to its failure to kill Thatcher and her ministers, the statement said: "Today, we were unlucky. But remember we have only to be lucky once. You will have to be lucky always."

The statement said that a bomb had been detonated "against the British Cabinet and the Tory warmongers. Thatcher will now realize that Britain cannot occupy our country, torture our prisoners, and shoot our people in their own streets and get away with it. Give Ireland peace and there will be no war."

The IRA has been carrying out a terrorist campaign against British rule in Northern Ireland for 15 years, during which more than 2,400 persons have been killed.

The IRA's goal is to force the British out of the six counties of the north that are part of the United Kingdom and unite them in a socialist entity with the Irish Republic to the south. The Protestant majority in Ulster wishes to remain part of Britain.

The attack drew expressions of outrage from all political leaders in Britain, from the prime minister of Ireland and many other national leaders.

About 12 hours after the bombing, when Thatcher appeared on the platform at the convention to deliver her keynote address, the strain of the bombing appeared to spill over into a prolonged and emotional standing ovation for her from the 5,000 attendees.

The attack, she said, "was an inhuman, undiscriminating attempt to massacre innocent, unsuspecting men and women. It was an attempt not only to disrupt and terminate our conference" but also "to cripple a democratically elected government."

"Not only has this attack failed," she said, but "all attempts to destroy democracy by terrorism will fail."

The early-morning blast rocked this venerable resort town on Britain's southern coast, scattering debris over a sea wall and onto the beach 100 yards away. It gouged a huge hole that made the seven-story hotel look like a tooth with a deep cavity. The IRA said the explosion was caused by a 100-pound gelignite bomb, but British police said it was a 20-pound bomb.

Thatcher said she was awake and working on her speech at the time of the blast. She and her husband Denis were whisked quickly out a back door by police and sped away in a black sedan.

Sources said the prime minister looked ashen and shaken by the blast, which blew out the windows of her suite. The suite of Foreign Secretary Geoffrey Howe, next to Thatcher's, also was heavily damaged.

When Thatcher arrived at the Brighton police station shortly afterward, she talked to reporters and looked remarkably poised and calm.

Many political commentators said Thatcher's steadfastness in public so soon after the explosion undoubtedly will fortify her image as the "Iron Lady."

Praising the police and firefighters, she said, "We were very, very fortunate. You hear about these bombs, these atrocities. You don't expect them to happen to you. Life must go on." So, too, she added, must the Conservative conference.

When the conference began in midmorning, Thatcher strode through the front door of the center, rather than using a rear entrance.

It is suspected that the bomb went off on an upper floor, perhaps the third or fourth, causing the top three floors to collapse and shower debris below.

The bomb exploded on the eve of the final debate at this year's conference, which was on Northern Ireland.

News agency reports from Ireland, and delegates here, said they believed the attack was also partly motivated by considerations of revenge for the Sept. 29 capture at sea of an IRA arms shipment, the largest arms seizure in Ireland in more than a decade.

It is also felt that the extremists still hold Thatcher responsible for the death of 10 hunger strikers who died in Belfast's Maze Prison in 1981 in a quest for status as political prisoners.

James Prior, former British secretary for Northern Ireland, said the group that planted the bomb may have been a cell of the IRA that operates in Britain but recently has been lying low.

In 1979, IRA and Irish National Liberation Army terrorists killed British member of Parliament Airey Neave, a close political associate of Thatcher, and Lord Mountbatten, cousin of Queen Elizabeth II. Six persons were killed and 94 others were injured in 1983 when a bomb went off at Harrods, a well-known London department store, at Christmas time.

What effect, if any, today's blast will have on British political life is not clear. Some members of Parliament said in interviews that it undoubtedly will cause tighter security and more restrictions on politicians. Others thought it could help bring the population closer together because of a sense that everyone is in danger.

No one here was publicly critical of security procedures and several police and political figures made the point that it was impossible to protect politicians at all times in a democracy. Security was tight at the convention center, where all bags of any kind were inspected by police. There were no metal detectors.

At the Grand Hotel where Thatcher, most of the Cabinet and scores of other party figures were staying, however, security was not nearly as tight.

There were numerous police in evidence, but people wearing conference credentials were not challenged going in and no bags were inspected. Normally, Thatcher does not stay in hotels, and the Grand, with its sweeping porch facing the sea, is an especially open place.

Eyewitnesses and officials here had high praise for the rescue workers. Firemen worked for four hours to dig Tebbit out of the rubble and for six hours to extract Wakeham. Other firemen strapped wounded guests to stretchers and hoisted them down on mechanical ladders from the upper floors.