The resignation of William D. Ruckelshaus after 18 months as head of the Environmental Protection Agency will leave a much-ballyhooed Chesapeake Bay cleanup program without its most powerful ally in the Reagan administration.

While lamenting Ruckelshaus' departure, officials from Maryland and Virginia expressed optimism yesterday that the cleanup project gained enough momemtum in Congress this year to survive intact. Federal funds totalling $52 million over the next four years for the federal-state program were authorized by the 98th Congress before it adjourned last month.

In contrast to his predecessor Anne Burford, who turned down invitations to meet with state officials concerned about the bay, Ruckelshaus became interested in the Chesapeake's pollution problems upon taking office. He toured the bay and subsequently met with officials and politicians from Maryland, Virginia, and Pennsylvania, to outline ways the three states and the federal government could work together in the cleanup program.

Ruckelshaus is credited widely with overcoming resistance from the Office of Management and Budget and persuading President Reagan to help finance the project, which emerged in the last 11 months as the Reagan administration's most celebrated environmental cause.

"Every oyster and crab and every duck and goose in, on and over the Chesapeake Bay is grateful to Bill Ruckelshaus," said U.S. Sen. Charles McC. Mathias, a Maryland Republican who a decade ago began a lonely crusade to halt pollution in the bay. "We hail him as an honorary waterman for life."

Mathias said he hoped Ruckelshaus' successor would have "the same grasp of facts and dedication to the quality of the environment."

Maryland and Virginia politicians were optimistic yesterday that the program would continue because Reagan had made a public commitment to it.

"We think even the most ardent environmentalist recgonizes that the president has so deeply committed himself publicly on this that it would be hard for him to pull back because of less vigorous support within the administration," said a spokesman for Maryland Democratic Gov. Harry R. Hughes.

"You've got to be concerned about it, but I think the bay is pretty safe," said an aide to Sen. John W. Warner (R-Va.). "The bay has tremendous support on the Hill."

By comparison to complex and costly problems such as toxic waste sites and acid rain, the relatively inexpensive bay cleanup became a natural vehicle for the administration to counter criticisms that Reagan had ignored the environment.

In the wake of scandals at EPA and the Department of Interior in 1983, Reagan in his State of the Union address earlier this year singled out the bay for federal funds. Last summer he toured the bay, accompanied by film crews from the Republican National Committee who used the footage during the presidential campaign this fall.

Since then, a host of federal agencies with responsibilities for the bay have pledged to move ahead collectively with the cleanup program.

Ruckelshaus, whose car bears a "Save the Bay" bumper sticker, ultimately succeeded in reversing years of federal lethargy on cleaning up the bay by generating bipartisan support on Capitol Hill and waging a relentless crusade within the adminstration.

"He represents the high-water mark of accomplishment on environmental matters for this administration," said one Maryland official who asked not to be named. "There wasn't much he could do for an encore."