A District man, released on personal recognizance last month by a D.C. Superior Court judge after he told police that he had robbed five Washington banks, was arrested yesterday by New York City police in the investigation of six bank robberies and seven attempted robberies there.

On May 8, Johnny Ray Harris, 26, was arrested inside an American Security Bank branch on East Capitol Street during at attempted robbery, 20 minutes after he had been involved in the robbery of a savings and loan here, according to a statement that police said Harris made. The day of his arrest, Harris told police that he had robbed five Washington banks and tried to rob two others within two months to support a heroin habit, investigators said.

The next day, Harris appeared in D.C. Superior Court for a bond hearing. Judge Gladys Kessler released him on personal recognizance and ordered him to enter the city's drug abuse program.

Harris never enrolled in the program.

Within a week of his release, police said, Harris robbed one Washington bank and tried to rob another.

Yesterday, Det. Sgt. John Kelly, a supervisor in the New York police department's bank squad, said police became convinced that the same man had staged a series of New York bank robberies after detectives had determined that notes handed to tellers in several cases appeared to have been written by the same person. He said police had staked out about six banks yesterday in an effort to capture that man.

But Harris apparently would have eluded the police dragnet had it not been for an alert patrolman in the Bronx who remembered having an encounter with a man Thursday at a motel near Yankee Stadium, Kelly said.

At 2:15 p.m. yesterday, Kelly said, a man robbed a Manhattan bank about 45 minutes after a bandit with a similar description had attempted to hold up another bank in the Bronx. When the suspect's description was broadcast over the police radio, the Bronx patrolman alerted detectives that a man who resembled the suspect was living at the Stadium Motor Lodge, which is located next to the 44th Precinct police station in the Bronx, according to Kelly.

Detectives subsequently arrested Harris without incident in the motel's lobby at about 3 p.m., Kelly said. Harris, who had been staying in a $38-a-night room, was registered as Raymond Jackson, according to Kelly. He had $1,308 on his person when he was arrested.

Later, Harris identified himself and gave a statement involving robberies of six New York banks and attempts to rob seven others since May 18, Kelly said.

Harris was charged in one New York bank robbery that ocurred yesterday and will appear today before a magistrate in an investigation that involves a total of 13 cases, Kelly said.

D.C. police detective William Wagner said last night that he will have a detainer placed against Harris for the charges here, which would prevent him from being released on bond in New York.

When Harris appeared in D.C. Superior Count for his bond hearing May 9, only one attempted bank robbery charge had been filed against him.

However, prosecutors are permitted to tell the judge at the bond hearing about other possible charges that might be filed.

D.C. police Detective Charles Dunn said taht when he turned the case over to the U.S. attorney's office May 9, he told officials that Harris was a suspect in six other cases and that he had a drug problem.

Robert W. Ogren, principal assistant U.S. attorney, said in an interview last month the usual procedure in such cases would be for the prosecutor to ask the judge to require the defendant to post a cash bond. Ogren said Harris should not have been released from custody.

Judge Kessler said last month, when a reporter asked why she release Harris, that she did not recall the case. She noted court files showed that she had followed the recommendation of the pretrial agency in releasing Harris. The report of the agency, a court unit that makes bond recommendations to judges, also said that Harris had four previous convictions.