John W. Hinckley Jr., the drifter accused of shooting President Reagan, was tentatively decared mentally fit yesterday to stand trial in the attempted assassination. But a federal judge ordered him to undergo further mental examinations, primarily to determine if Hinckley was sane at the time of the shooting.

Hinckley, wearing a white bulletproof vest under his dark blue suit jacket as he sat passively at the defense table, appeared in U.S. District Court for a total of 38 minutes. Dozens of police and U.S. marshals stood guard both inside and outside the courthouse, and even reporters and top Justice Department officials attending the hearings were thoroughly searched.

The scheduled purpose of Hinckley's court appearance was for the government to generally outline its evidence that Hinckley allegedly tried to assassinate President Reagan outside the Washington Hilton Hotel on Monday and that Hinckley should remain in custody while a federal grand jury considers an indictment.

But that business was cast aside quickly when Hinckley's lawyers waived his right to a preliminary hearing and Hinckley, standing and rocking back and forth on his feet, agreed with them by uttering softly "Yes, sir" and signing his name to the waiver document with his left hand.

Hinckley's lawyers -- faced with evidence said to include videotapes of him firing at the president and a letter to actress Jodie Foster saying he would shoot Reagan in an effort to impress her -- said in court that they were considering entering a plea of not guilty by reason of insanity. His parents have said he was under psychiatric care for five months before the shooting.

However, U.S. Attorney Charles F. C. Ruff asked that the government be permitted to thoroughly examine Hinckley's mental state before a team of defense psychiatrists hired by Hinckley's lawyers.

U.S. Magistrate Lawrence S. Margolis granted Ruff's request, and Hinckley's lawyers immediately appealed the Margolis decision. But early yesterday afternoon, District Court Chief Judge William B. Bryant upheld the decision and ordered Hinckley sent to a federal mental prison in Butner, N.C., for tests that could last 90 days or more. He was flown there under heavy guard yesterday afternoon.

While the debate over legal technicalities affecting the 25-year-old alleged presidential assailant unfolded in court yesterday, the search for a motive for the shooting and the nationwide FBI hunt to track Hinckley's activities for the past year continued throughout the country:

Near Evergreen, Colo., a nextdoor neighbor of Hinckley's parents told reporters that, according to the Hinckley family, a young man photographed at a Nazi rally in St. Louis in 1978 and reported to be Hinckley is someone else. "In my judgement, it bore no resemblence to John," neighbor William Sells said of the photo. Hinckley had been a member of a neo-Nazi organization for a short period during his wandering around the country, but was expelled by the group's leaders because they found him "too extremist."

Federal investigators said they believe Hinckley went to Los Angeles before coming to Washington to pick up a .22-caliber handgun similar to the one allegedly used to shoot Reagan and three others Monday. Hinckley had purchased two such guns in Dallas late last fall.

He had lived in Los Angeles several years earlier, and had apparently gone back there sometime between the handgun purchases in October and his March 25 departure from Denver for Washington, the sources said.

Sources at Yale University said yesterday that Foster, who is enrolled as a freshman there and whom, sources say, Hinckley pursued with obsession for seven months, received more than a half-dozen letters signed with Hinckley's name or initials. A source said, however, none of the letters mentioned Reagan.

Hinckley, who investigators believe acted alone in Monday's shooting, is charged with attempted assassination of a president and assault on a federal employe -- a Secret Service agent wounded in the attack. Conviction on the former charge could result in a sentence of life imprisonment.

Further charges stemming from the wounding of Reagan press secretary James S. Brady and a D.C. police officer are under consideration. Hinckley, the son of a wealthy Western oilman, has been ordered held without bond since shortly after his arrest immediately following the incident.

Shortly after yesterday's initial hearing began, a report was presented from James L. Evans, a court-appointed psychiatrist who had examined Hinckley for three hours Wednesday at Quantico Marine Base. TIn a brief, one-paragraph statement read to the court, Evans said that he found Hinckley was able to understand the charges against him and was capable against him and was capable of assisting in his own defense -- a routine, preliminary finding of mental fitness to stand trial that was accepted by Hinckley's lawyers and Magistrate Margolis.

However, Judge Bryant ordered that further tests be conducted to help determine Hinckley's fitness to stand trial, which is separate from the more complex issue of whether he was sane at the time of the assassination attempt.

But Hinckley's chief defense counsel, Vincent J. Fuller of Williams & Connolly, said such an examination for his sanity would be premature because the defense had not decided whether it would make such a plea.

"We are concerned . . . that government [mental experts] have not access to the defendant prior to our having done so on our own terms," Fuller said.

Ordinarily, it is the defense lawyers who request such hospitalization to determine mental competency. Ruff's early request to do so appeared to indicate that federal prosecutors are anxious to block an insanity plea.

Although Bryant's order gives the defense team equal access to Hinckley, it will be the government staff that has him under constant observation while he is confined in the federal facility -- granting them what one observer said yesterday would be "the first crack" at evaluating Hinckley's mental state.

Legal sources familiar with the case said that prosecutors are probably concerned that if the government's mental examination takes place after the defense conducts its evaluation, the defense might later at trial challenge the validity of the government's findings.

"It's the beginning of the battle of the experts. It's the first volley," one source said.

Legal sources said yesterday that pleading not guilty by reason of insanity is a difficult defense in such cases, particularly those involving violent crime. In such cases, it is up to the defense to prove that the defendant was mentally ill at the time the crime was committed.

Sirhan B. Sirhan, Robert F. Kennedy's assassin, Jack Ruby, who shot Lee Harvey Oswald in front of television cameras and Arthur Bremer, the man who shot former Alabama Gov. George C. Wallace, all pleaded insanity of one form or another. All three were subsequently convicted, nevertheless.

"You just don't win in violent crimes. The jury is afraid of what might happen," one lawyer familiar with such defenses said yesterday.

Federal law governing criminal insanity in Washington is similar to that in other jurisdictions in that a person can be declared innocent if it can be proven that at the time of the crime, the person either lacked the capacity to act in conformity with the law or was unable to understand that certain action was illegal.

In addition, the federal court of appeals here has ruled that even if the defendant does not meet either of those two criteria, the defendant can claim that "diminished [mental] capacity" prevented the person from carrying out a premeditated or deliberate act.

The letter to actress Foster found in Hinckley's hotel room indicates an awareness that an attack on the president could be suicidal. "There is a definite possibility that I will be killed in my attempt to get Reagan," the letter said. "It is for this very reason that I am writing you this letter now."

But, the writer concludes, "By sacrificing my freedom and possibly my life, I hope to change your mind about me. This letter is being written an hour before I leave for the Hilton Hotel."

It is signed, "I love you forever, John Hinckley."

Foster's most famous movie role was that of a runaway teen-age hooker in the 1975 film "Taxi Driver," which some investigators feel has a plot with a bizarre parallel to the Hinckley case. In that film, the hacker. pa mentaly troubled Vietnam veteran, stalks a political candidate and is preparing to assassinate the politician before he is scared off by a security agent.

It is not known whether Hinckley saw the movie.

In recent years, Hinckley seemed to have become estranged from his wealthy family, traveling about the country without their knowledge, and living in cheap motel rooms.

Shortly after Hinckley's arrest his father, who is chairman of the board of Vanderbilt Energy Corp., a Denver-based petroleum exploration company, hired members of the well-known Williams & Connolly firm to represent his son. The firm's three-man defense team replaced two attorneys who were appointed to represent Hinckley after he told court officials he could not afford to hire a lawyer.

Yesterday, Hinckley neighbor Sells said Hinckley's parents "hope to see their son as soon as possible."