Spirits soared at the ultramodern Allied Irish Bank headquarters here last week where Ireland's most aggressive bankers celebrated the biggest coup in Irish banking history--the impending takeover of First Maryland Bancorp.

The move will increase Allied Irish's assets by 40 percent overnight, giving them a commanding lead over their chief competitor, The Bank of Ireland, in the race to be the largest banking institution in the country.

"We're really pleased," bubbled Gerald B. Scanlon, Allied Irish's general manager in charge of development and the architect of the startling move by Ireland's largest bank. "Everything has gone smoothly and we are right on schedule with the acquisition."

Adding to Scanlon's delight was the fact that the $150 million takeover was conducted in total secrecy over a period of 16 months--and this in a country which offers the same amount of privacy as a small town. In spite of dozens of transatlantic trips and hundreds of telex and telephoned messages, the deal went off without a single leak to the press, employes or shareholders.

From the beginning the operation was top secret. The acquisition attempt was given the code name "Marilynn" by the 10 Allied Irish officials involved and all memos and messages pertaining to the move used the secret word to ensure that rival Bank of Ireland officials would not get wind of the takeover. Allied Irish executives even went so far as to disguise First Maryland's bankers, who arrived in Dublin last fall simply as "businessmen from the Baltimore-Washington area."

"We were also afraid that the IDA the Irish Industrial Development Authority, which tries to entice foreign industry to Ireland would hear they were in town and try to get to them," Scanlon said. "I was on tenterhooks the whole time they were here."

Allied Irish officials first considered buying a U.S. bank in October 1981, immediately following a management reshuffle which was aimed at putting more emphasis on "strategic planning" for the future.

Several factors made the move attractive at that time. First was the Irish government's introduction of steep bank levies, which the industry has repeatedly criticized as arbitrary and unrelated to earnings. Second was the government's mandated lending ceilings, which have, for the past four years, severely restricted growth.

Ironically, the depressed state of the Irish economy, plagued with a 12 percent inflation rate and 14 1/2 percent unemployment, has nullified the effect of the lending limits. Allied Irish spokesmen say the 11 percent ceiling in effect this year is under no pressure and last year's 14 percent limit was not reached by any of the large banks. This sharp decline in growth was particularly painful to Allied Irish, which has enjoyed steady expansion for the past 15 years with assets now reaching $8 billion.

On the positive side, Irish bankers regard the likelihood of a rapid American recovery from the current recession as one good reason for expanding operations in the United States. In addition, they are hopeful that President Reagan's promise to deregulate the U.S. banking industry will allow Allied Irish to snap up other American banks through First Maryland Bancorp.

Although Allied Irish already has branches in New York and Chicago, it was prohibited from further expansion under the 1978 International Banking Act. The only way to increase its presence in the United States was to buy a bank of its own.

The Allied Irish decision to take over an American bank is not so shocking, consiering the group's history. In 1970, it opened its first branch outside Ireland--in London--and within 13 years had opened 60 more British outlets. In addition to those in England and the United States, Allied Irish has branches in Brussels, Frankfurt, Jersey in the Channel Islands, the Isle of Man and has an application pending in Singapore for a branch there.

In February 1982, Allied Irish made its first definite move toward a U.S. acquisition by hiring Morgan Guaranty Trust in New York to find the bank a suitable American institution. Irish officials originally planned to purchase 100 percent of a bank but were persuaded to accept a simple 51 percent majority by Morgan Guaranty.

It took seven months for Morgan to settle on First Maryland as a bank that was the right size and compatible with Allied Irish's requirements. Allied Irish officials say they were looking for a bank that was more wholesale than retail oriented. First Maryland, with its mixture of 60 percent wholesale and 40 percent retail business fit the bill.

Bank officials here stress that from the first meeting last September there was instant compatibility between the Maryland managment and their Irish counterparts.

The rapport was so strong, in fact, that Allied Irish has requested that senior First Maryland executives stay on in their present positions and sign long-term contracts. Reportedly, none of these contracts have been signed yet, although they are said to be part of the overall acquisition package.

By last November, when a group of First Maryland Bank executives arrived in Dublin for a series of meetings, the deal was set in motion. Included in the Maryland contingent was J. Owen Cole, chairman and chief executive of First Maryland, Charles Cole, president, and Executive Vice President Bob Schaeffer.

The first snag in the takeover came on the morning of Friday, March 5, when trading of First Maryland shares had to be suspended because the stock was beginning to move and it was obvious that news of the acquisition had gotten out.

Here in Dublin, however, the only indication that Allied Irish might be up to something was a small notice in a business weekly suggesting that because Irish bankers were making an inordinate number of trips to the United States, perhaps the purchase of an American bank was under way. The article gave no indication that the announcement was imminent and, in fact, speculated that it was a Massachusetts bank under consideration.

The weekend was a hectic one for Allied Irish executives trying to hammer out a final agreement via telex and telephone. By 8 p.m. Sunday (Irish time) it appeared that the deal was ready to go and it was agreed that simultaneous signing of the papers would take place at the beginning of business of Monday. The Allied Irish board of directors was not told of the takeover until Monday morning, giving them just a few hours to meet, discuss and vote on the move. At 9 a.m. Washington time (2:00 p.m. in Dublin) the agreements were signed.

Problems still remain with the takeover, especially in the area of banking regulations. But the Irish bankers seem curiously unconcerned about the legal obstacles.

Allied Irish executives appear caught in a dichotomy when trying to explain what their role will be in the new bank. On one hand, they are anxious that Americans believe this will be the same institution they have been dealing with in the past. On this side of the Atlantic, however, Allied Irish is trying to quell suspicions that the takeover is a vote of no confidence in the foundering Irish economy and the first step toward an eventual withdrawal from the country altogether.

Allied Irish group executive Patrick O'Keefe appeared on Irish television last Monday night in front of the bank's headquarters in the exclusive Ballsbridge section of Dublin, asked the Irish public if they thought the bank would be so foolish as to build such a complex if its management intended on leaving the country.

When asked if it was true that Allied Irish had finally outgrown the Irish economy, another Allied Irish executive, Gerald Scanlon, replied: "I prefer to say we're not outgrowing Ireland, we're growing out of Ireland.

"We're Irish. We're proud to be Irish. And we're going to stay Irish," he said.