When state Sen. Howard A. Denis (R-Montgomery) spoke at a fund raiser for Republican legislators two weeks ago, the first thing he did was invoke the name of a Democratic candidate for governor.

"In case you are waiting to see Mayor Schaefer," said Denis to the crowd of GOP partisans gathered at the Elks Lodge here, "he only goes to one Republican fund raiser a week."

Denis' quip was a wry reminder of Baltimore Mayor William Donald Schaefer's controversial appearance at a Republican congresswoman's bull roast on March 9, the day he passed up his party's annual dinner. It was also a commentary on the mayor's sometimes heretical brand of Democratic politics and his stature as a celebrity candidate who can openly flout convention because his appeal transcends the party and its traditional constituencies.

Schaefer's breach of partisan etiquette six months before the Democratic gubernatorial primary served to highlight the fundamental differences in style and philosophy between the mayor and his rival for the nomination, state Attorney General Stephen H. Sachs. And it provided Sachs a jumping off point for an emerging campaign theme that will attempt to portray Schaefer as a man whose commitment to fundamental Democratic principles is as tenuous as his allegiance to party protocol.

In the primary contest between Sachs and Schaefer, Maryland's Democratic voters will have one of their clearest choices ever, one that may well be a local version of the national Democratic Party's struggle to define itself in the wake of presidential candidate Walter F. Mondale's devastating general election defeat in 1984.

In Sachs, voters have a liberal attorney general whose political rhetoric evokes memories of FDR and John Kennedy, and whose campaign is in many ways directed at the old Democratic coalition of labor, women, minorities and seniors. Sachs says he believes that these politics can capture the public imagination in a heavily Democratic state that supported Mondale in the presidential primary two years ago.

In Schaefer, voters see a big-city mayor whose credo is getting things done, whose strongest ties are to business, and whose centrist appeal transcends party and interest groups. Schaefer's politics are Reaganesque in relying on personality, image and media. And, judging by Schaefer's early lead in the polls, they are effective in a state that in the 1984 general election voted for the president..

Schaefer's combination of pragmatism and moderate politics, while hardly new for him, puts him in sync with such national Democratic moderates as Arizona Gov. Bruce Babbitt and Missouri Rep. Richard A. Gephardt who are seeking to broaden the party's appeal by questioning some of its orthodox tenets.

Sachs' blend of New Deal causes, social activism and belief in government regulation mirrors the approach taken in national Democratic circles by Delaware Sen. Joseph R. Biden Jr., who is busy warning his party not to abandon its heart in the aftermath of 1984.

"It's one of the great contrasting races in Maryland history," observed Blair Lee IV, Sachs' campaign manager. "No one is going to call these guys two peas in a pod or Tweedledum and Tweedledee."

The differences between the two gubernatorial candidates is already reflected in how they are approaching the campaign.

Even though Schaefer has not yet formally announced his candidacy, he is running hard for the governor's office and has increased his travels around the state, talking to local chambers of commerce, Rotary Clubs and similar organizations.

Sachs, meanwhile, has successfully courted the traditional endorsements of labor, blacks and seniors.

Sachs has spent more than a year building a grass-roots organization with branches in each of Maryland's 24 local jurisdictions. Schaefer's network is at this stage far less formal, and it is expected that his campaign will depend heavily on television, a luxury he can afford because he will have an ample war chest.

In a similar vein, Sachs has wooed the kind of veteran Democratic activists who attend the party's annual dinner meeting. Schaefer not only skipped the dinner, but he also has attended at least two affairs for members of the Republican Party in the past two months, including the roast for Rep. Helen Delich Bentley.

Schaefer's bypassing of the party apparatus and the endorsement game is "the way executives normally run," said Democratic pollster and political consultant William Hamilton. "Guys who have centralized media control have the ability to do their politics above everything else. Factions are not where they derive their power from. Schaefer just carries the independence thing to an extreme."

As Sachs attempts the daunting task of weaving together the traditional Democratic fabric, his rhetorical thread is this: The Sept. 9 primary is really a general election pitting the attorney general against an opponent who is a Republican in everything but name.

"The mayor is very Reagan," said Sachs. "In a real sense this race for the leadership of the Democratic Party is a race between a Democrat and a Republican."

A former federal prosecutor who specialized in white-collar crime cases, Sachs, as attorney general, has been an aggressive consumer protection advocate. He has zealously pursued antitrust and hazardous waste cases, all of which has caused him substantial political problems with Maryland's business community. He has also fought banking deregulation and advocated the deinstitutionalization of the state's mentally ill.

"I am very much a product of the traditional values of the Democratic Party," added Sachs. "I'm not neo-anything. The idea of government being necessary to promote fairness, to protect the vulnerable, as a tamer of the jungle, as a necessary regulator, are things I believe . . . . The mayor doesn't appear to share this vision. The mayor has become mesmerized with the corporate community -- he worships now at the altar of the free market."

Sachs partisans offer a number of examples of what they see as Schaefer's weak ties to the Democratic Party and its principles. Among them:

*What Sachs charges is the mayor's overemphasis on economic development in Baltimore and the "privatization" of government while ignoring the needs of the city's poor. Lee, Sachs' campaign manager, calls it "trickle down" economics in the Reagan mode.

*Schaefer's refusal to pledge support of the Democratic gubernatorial nominee if Schaefer loses.

*Schaefer's flirtations with Republican standard-bearers, from gubernatorial candidate Robert Pascal in 1982 to Ronald Reagan in 1984. Schaefer shared a platform with Reagan shortly before the presidential primary when Reagan came to Baltimore to dedicate a statue of Christopher Columbus.

*The mayor's decision to pass up the 1984 Democratic National Convention in San Francisco, where he was guaranteed a delegate's seat, and his visit the same week to the San Diego Zoo.

Mark Wasserman, Schaefer's campaign manager, dismissed Sachs' charge that the mayor is a City Hall version of Reagan as "self-serving, unadulterated claptrap" and said the mayor's commitment to social programs can be observed by "walking through any neighborhood in Baltimore and talking to the people."

The question, of course, is whether such things matter to the typical Democratic voter.

On a recent campaign tour of several unionized clothing factories in Western Maryland, Sachs hammered at the message that he has been endorsed by the Amalgamated Clothing and Textile Workers Union as he handed out a brochure that compared his labor record with Schaefer's. "The Amalgamated says I'm okay," Sachs told hundreds of female textile workers hunched over sewing and pressing machines in plants in Hancock, Halfway, Boonsboro and Frederick.

To workers in an industry hit hard by imports, the contrast was clear. There was Sachs, in a suit with the union label sewn inside the pocket, handing out brochures describing a speech by Schaefer in which he "bemoan[ed] American workers' productivity versus that of workers in Taiwan, Japan and China."

But a number of the workers said their union's endorsement of Sachs would play at most a minor role in their votes in September.

The endorsement "doesn't affect me one way or the other," said Mona True, 48, of Hancock.

Sachs' supporters often cited reasons other than his strong prolabor record for backing him.

When asked why she is for Sachs, Dolores Fling, a 52-year-old presser from Hancock, replied: "He seems like an average person. You can talk to him like I am talking to you. I've never heard Schaefer speak."

Sachs' problem in translating the union's endorsement into rank-and-file votes was raised by 65-year-old Mary Ellen Ogle, who has worked in the Frederick suit factory owned by the Hartz company for 50 years.

"This is not a political plant," said Ogle, an avid Sachs partisan. "The young people aren't very interested in politics."

Sachs' many endorsements, said Schaefer manager Wasserman, will ultimately prove futile in the face of Schaefer's appeal to "just plain people who have been touched by him."

"People want somebody who's experienced, who knows how to handle the reins of government," added Wasserman. "I'm not sure people want to be lumped into categories and taken for granted."

Also, some Maryland politicians believe that Schaefer's aloofness from the Democratic Party structure is an advantage.

"I don't think it's bad politics for the mayor," said state Sen. Stewart Bainum Jr. (D-Montgomery) of Schaefer's attendance at a Republican fund raiser. "People want someone in office who is not just a partisan person. It doesn't stand him in good stead with the activists, but there are only a few hundred of us."

But Lee, Sachs' campaign manager, suggests that there is a potent message beneath the symbolism.

"You're not going to find us saying, 'Isn't it horrible Schaefer doesn't attend Democratic functions,' " said Lee. "But we are going to say this Schaefer is a Democratic Reagan who thinks like Reagan, talks like Reagan and is a Reagan."

"I'm not sure it's a winner," concluded Lee, "but Sachs doesn't care. Some of these campaigns go beyond politics and become battles of philosophy and ways of thinking. This one is shaping up that way. What you have is a microcosm of the whole national Democratic quandary, and that's what makes it interesting."