The prominent and the lowly said farewell to Rep. Leo J. Ryan yesterday to the strains of a Navy hymn which on another sad November day 15 years ago had haunted the streets of Washington.

On this sullen and rain-spattered afternoon in the hills of South San Francisco the anniversary of John F. Kennedy's death was on the minds of the politicians who flocked here from Washington, D.C., and San Francisco for Ryan's quiet funeral service.

"It's hard to do anything because everyone in San Francisco feels the way they did after the Kennedy assassination," said grim-faced San Francisco Mayor George Moscone before the service. "We're sick about it. It's just too much."

Inside the modern All Souls Catholic church where Ryan's body lay in a closed casket draped with an American flag, a Navy choir sang the hymn for departed sailors requesting by Ryan in his will while Ryan's daughters and others dabbed at their eyes.

Joe Holsinger, Ryan's longtime aide and friend, remembered the slain congressman as an impatient, restless, hard-driving man who frequently lost his notes, his schedule and his keys.

"We never could keep Leo in keys," Holsinger said.

But he remembered Ryan, too, as a man who went where others in public life were afraid or unwilling to go. The most revealing insight of Holsinger's soft-spoken eulogy came from a conversation that Ryan had with the NBC camerama Bob Brown, who also was shot to death last Saturday on the airplane runway in Guyana where Ryan died.

On flight to Guyana, Brown and Ryan chatted about a voluntary stay Ryan had made in Folsom Prison in 1970 in an effort to learn about prison conditions. Brown wanted to know what was the most important thing that Ryan had gained from the experience.

"I learned that if you give in to fear you can't do your job," Ryan replied.

And Ryan, as Holsinger and House Majority Leader James Wright (D-Tex.) described him was the man who consistently did do his job. Wright told of how Ryan served as a substitute teacher in Watts, a black Los Angeles neighborhood, to learn about conditions in the ghetto and how he went to Newfoundland to see for himself about the slaughter of baby seals.

"Leo Ryan was his own man, too much an individualist to be compartmentalized," Wright said.

It was this "ever-ready willingness to go where suffering was," as Wright put it, that those who spoke of Leo Ryan found most distinctive about him.

Holsinger recalled that Ryan had enlisted in the Navy when he was 18 years old and that he had subsequently, as a young school teacher, entered politics for "negative reasons" - because he detested the attacks on civil liberties made by the Sen. Joseph McCarthy (R-Wis.).

Afterward, said Holsinger, Ryan became interested in reforming the city council in South San Francisco and launched on a political career that continued until he was killed in Guyana last Saturday.

Holsinger said that as councilman, mayor, state legislator and congressman, Ryan's ideal was one of constituent service in which his votes were cast for those he represented instead of for himself. He met people in their homes and he talked to anyone, in his district or Washington, who wanted to meet with him.

"He instructed his staff never to turn anyone away," said Holsinger. "He said that this is the people's office. They're paying for it. He personally read every letter."

The service was attended by Ryan's former wife, his five grown children and by various family friends and local dignitaries. It was also attended by scores of congressmen and legislators who had served with Ryan, by the president's son Chip Carter, California Gov. Edmund G. (Jerry) Brown Jr., and Sen. S. I. Hayakawa (R-Calif.) who seemed to be asleep during much of the service.

After the service a funeral procession wound through the rain-drenched hills of this working-class suburb-hills containing the "ticky-tacky boxes" of subdivisions which first inspired the phrase - enroute to Golden Gate National Cemetery.

It was Ryan's wish, expressed in his will, that he be buried in this cemetery, "so his ghost will be looking out over the bay he loved so much."

The graveside service was brief, tightly guarded and heavily naval in character. Father Thomas Parenti of Our Lady of Mercy Church in Daly City read a brief Catholic burial rite that was drowned out for many by three police helicopters circling over-head.

An honor squad of seven Navy riflemen fired a 21-gun salute. A Navy bugler played "Taps." A rainbow appeared in patches of blue sky amid the dwindling rain.

"Today, Leo is here where he first served us," Parenti said. "Today, Leo Ryan is home."