In the closing hours of the cliffhanger contest for Maryland's second congressional district, aides to Republican Helen Delich Bentley rushed a last-minute radio ad to stations all over the district.

The message was simple. Vice President Bush, taped at a rally last weekend for Bentley, said, "The reason I'm here today is to stand at Helen Bentley's side and strongly urge you to support her . . . you must send her to the Congress."

It was a White House annointing of Bentley that ran more than 50 times on election eve, and it worked. By midnight Tuesday Bentley, a feisty former Nixon administration official, had ridden President Reagan's coattails to a narrow victory over 11-term incumbent Democrat Clarence D. Long. It was her third try for the office.

"If there is one congressional race in the country that you can attribute to the coattail effect, this was it," said Baltimore County Executive Donald Hutchinson, a Democrat and staunch Long backer.

Bentley acknowledged the importance of the president's popularity in her victory. In an interview today, she said that her position on the ballot, right next to Reagan and Bush, had helped win votes. Democrat Hutchinson had pointed to the same factor.

"Even if there had been a blank space between the names, people who were undecided might have voted for Long," he said. "But instead, this looked like the Republican team, Reagan-Bentley, and people said, this is where I want to be today."

Bentley came out of the election with 51 percent of the vote, a 5,752-vote margin over Long. The count of about 7,000 absentee ballots will not be completed until Thursday. However, Long acknowledged in a press conference today in his Towson office that those ballots would not be enough to offset Bentley's victory margin.

Though Long agreed that Reagan's popularity had helped his opponent, he pointed to another factor for his defeat: the 1981 redistricting in which he lost his major stronghold, the liberal, Jewish Baltimore community of Pikesville. In its place he was given a huge chunk of conservative, Republican Harford County.

"Coattails or not," Long said today, "if it hadn't been for reapportionment, I would have won."

Long had cultivated Pikesville's Jewish constituency with an unflagging loyalty to Israel and the powerful chairmanship of the House subcommittee that doles out foreign aid. "Long was so excessively pro-Israel that Menachem Begin looks bad by comparison," said Phil Jacobs, an editor at the Baltimore Jewish Times.

Fearing that he would have to ride out a Reagan landslide, Long began campaigning early and collected large amounts of money from pro-Israel friends all over the country. He outspent Bentley 2 to 1 what appears to be the most expensive congressional contest in Maryland history. Together he and Bentley spent more than $1.2 million on the race.

But Long's effort, helped by other popular Maryland Democrats including Hutchinson and Sen. Paul S. Sarbanes (D-Md.), was not enough this year.

In 1982, the first time Long ran in his newly apportioned district, he beat Bentley by more than 8,000 votes. But this time around the popular president brought out the Republican voters in Harford County, where Bentley's 1,200-vote lead in 1982 swelled to a margin of more than 4,500 votes, according to Long aides.

Bentley aides assert that another key to her success was the ability to cut into Long's remaining stronghold, the blue-collar areas of Dundalk and Essex, where they targeted Democrats set to cross over to President Reagan. There, Bentley was able to cut Long's margin of victory by about five percentage points and that, they say, pushed her over the top.

Long, a 75-year-old maverick Democrat, has been a consistent thorn in Reagan's side on foreign affairs issues. Bentley, 61, a dogged Reagan follower, said today she will support the president on such issues as his quest for line-item veto power and a balanced budget amendment. She also said she will concentrate on local issues.

Long's defeat will cut Maryland's representation on the powerful House Appropriations Committee to one, Rep. Steny H. Hoyer (D), who ranks low in seniority.

"This removes a considerable obstacle that has been there for the president," said Steve Lotterer, spokesman for the National Republican Congressional Committee. "It is a great victory not only for Helen Bentley but for the Republican party."