Gilbert Gude, a former Montgomery County congressman who has headed the Library of Congress' Congressional Research Service for nine years, said yesterday that he would retire, setting off speculation that the moderate Republican would run for the seat being vacated by Sen. Charles McC. Mathias (R-Md.).

However, Gude, 62, laughingly quashed the rumors, saying his current interests are writing and the Potomac River, not politics. Gude, who will leave his post Dec. 15, plans to write a book about the future of small-town life, focusing on five towns along the Potomac.

Gude is the author of "Where the Potomac Begins: A History of the North Branch Valley," an ecological tale of two mining towns. The former representative, whose family founded a widely known florist and nursery business here, has long been interested in environmental matters.

"I've achieved a lot of things I wanted to do in the job. Now I'm looking at other things over the horizon," said Gude.

Gude's announcement startled many of his colleagues at the library, much as his announcement in 1976 that he would not be seeking a sixth House term stunned his colleagues, friends and family.

Maryland Republicans, who have had difficulty finding a strong Senate candidate, excitedly speculated yesterday that Gude might run.

Cast from the same moderate GOP mold as Mathias, he was seen by many Republicans as a choice candidate in the heavily Democratic state. They noted that Gude was enormously popular in Montgomery, turning the largely Democratic 8th District into a safe Republican seat.