Until recently, national and state Republican strategists thought Harlan C. Williams, a 57-year-old Realtor from Cecil County, would be the ideal candidate to run against two-term Democratic incumbent U.S. Rep. Roy Dyson for Maryland's 1st Congressional District.

With President Reagan at the top of the ticket in a district that Reagan is favored to carry easily, Republican officials were optimistic they could sell voters on Williams' hard-core conservative politics and return the seat to GOP control.

The 13-county district, Maryland's bedrock of conservatism on the Eastern and western shores of the Chesapeake Bay, had a 20-year streak of sending Republicans to Capitol Hill until 1981.

Even today, Williams' campaign for Congress has all the trappings of success, including a double-decker British campaign bus and a glossy six-page campaign brochure.

But now, on the eve of the election, the 35-year-old Dyson appears a safe bet to win his third term, Republican officials privately concede.

A Dyson victory would effectively cement one of only two Republican strongholds in Maryland in Democratic hands. "I still think this district should be in the Republican column," says Allan C. Levey, chairman of the Maryland GOP.

"But it's very difficult to beat an incumbent. Sometimes it takes more than one race."

Nowhere else in the state have GOP fortunes diminished as rapidly as in the 1st District, where the party's only hope in this predominantly Democratic state seemed to be former Republican congressman Robert Bauman.

Bauman, a right-wing rising star in the state GOP who harbored hopes of running for U.S. Senate, had followed a long list of Republican congressmen from the district, including Rogers C. B. Morton, later a Cabinet member in the Nixon administration.

Bauman, like his predecessors, had built a solid organization that kept the district firmly in GOP control. But three years ago he resigned after admitting that he had solicited sex from a teen-age youth.

The revelations of his homosexual activity uncovered deep chasms in the local party and when Bauman sought reelection in 1982, he was defeated by Porter Hopkins in a campaign primary distinguished by its nastiness.

To overcome the divisiveness of that campaign, local Republican leaders began last year to try to unite behind a compromise candidate, Williams, who had been active in local Republican politics.

Armed with Dyson's ratings from public interest groups, Williams has sought to portray the incumbent as "a House Speaker Thomas P. Tip O'Neill type of Democrat who has voted with the labor unions 85 percent of the time."

"Dyson and I differ much more than people would like us to believe," Williams said in a recent interview. "He's very much involved with the liberal House leadership. He's one of the biggest spenders in Congress."

"The base problem," says Williams, "is that we are spending too much and it's the average guy who is supporting this socialistic trend in government."

Besides supporting government cuts in social services, Williams favors a constitutional amendment prohibiting abortion and opposes the Equal Rights Amendment.

Williams, who has never held elective office, says Dyson is "an opportunist" who has tried to take credit for pork-barrel defense projects that he says were really the work of the Reagan administration.

Dyson seems unfazed. "He's helping me by calling me a liberal," Dyson said at a fund-raiser in Queenstown this week. "It's not going to hurt me at all.

A conservative on economic issues and a supporter of a military buildup, Dyson has been careful to distance himself from Democratic presidential nominee Walter F. Mondale, although he has stated publicly that he supports the Democratic ticket. "In this region a lot of voters want to vote Democratic but are going to hesitate in voting for the Democratic nominee," Dyson says. "I give them the opportunity to vote for a Democrat."

Says Dyson supporter Jim Voss, a farmer from Caroline County and the area's coordinator for the Mondale-Ferraro ticket: "Who's kidding who? Roy is no liberal. He represents the people of his constituency."

Dyson has also mastered the politics of incumbency, which is serving him well in this campaign.

One Saturday morning last month, thousands of his constituents received free donuts on their doorstep, courtesy of the congressman. There is a a billboard on Rte. 50 east of the Bay Bridge that proclaims: "Congressman Roy Dyson Welcomes You to the Eastern Shore."

He has used his congressional newsletter so much to showcase his accomplishments, particularly a bill he sponsored this year authorizing federal funding to clean up the Chesapeake Bay, that Williams has accused him, to no avail, of ethics violations.

And, in the congressional jurisdiction geographically comprising 60 percent of Maryland, Dyson has been to "every chicken dinner and every farm queen contest," according to an aide.

For his part, Williams is still optimistic, although he acknowledges it is an uphill battle.

"In some ways I wish I still had a year to campaign," he says, "and in some ways I wish it was over tomorrow."