The two Democrats who would be governor had just finished making the rounds in a large banquet room when Maryland Comptroller William Donald Schaefer took the stage.

Minutes into his rambling talk, Schaefer (D) committed what would have been considered a major faux pas coming from most any other politician: He showered praise on a Republican his party is trying to unseat next year -- Gov. Robert L. Ehrlich Jr.

"He's done a marvelous job," Schaefer told the crowd of about 500 municipal officials. "He's done a marvelous job."

Since his arrival in office in 2003, Ehrlich has worked hard to court the affections of the cantankerous former governor and former mayor of Baltimore, and last month's validation in Ocean City was among the latest fruit to emerge from those labors.

More can be seen on TV. The 83-year-old Schaefer -- a longtime contrarian who feuded openly with the state's last Democratic governor, Parris N. Glendening, and who skipped last year's Democratic National Convention after a spat with party leaders -- is appearing alongside Ehrlich in a campy commercial. In it, the two show up unannounced at a family's home -- before 6 a.m. -- to help pack their car for a beach weekend.

There's also a radio version of the ad, as well as a billboard in Baltimore featuring Ehrlich and Schaefer that could be mistaken for an endorsement from a Democrat who backed President George H.W. Bush.

The $600,000 advertising campaign is part of a state effort to encourage beachgoers to travel at off-peak hours and take other steps to reduce backups on the overburdened Chesapeake Bay Bridge. But Democrats have said the ads represent another attempt by Ehrlich to promote himself at public expense.

Schaefer's involvement, they have said, is particularly troubling because of the signal it sends: He represents a conservative wing of the Democratic Party, whose crossover votes will be crucial to Ehrlich's chances of reelection in a state where Democrats hold a nearly 2-to-1 edge over Republicans in registration.

"I don't know that William Donald Schaefer understands the effect of what he's doing, and quite frankly, I don't know that he cares," said Senate President Thomas V. Mike Miller Jr. (D-Calvert), who credits Ehrlich with having "seduced" the comptroller. "As a political strategy, it's worked very well."

It would be difficult for Ehrlich to have a worse relationship with Schaefer than Glendening had.

In Schaefer's mind, the dysfunction was symbolized by Glendening's decision to turn off an ornate fountain, on the lawn of the governor's mansion, that had been commissioned by Hilda Mae Snoops, Schaefer's longtime companion.

Glendening -- whom Schaefer referred to as "that dummy" during an interview for this article -- cited drought-related restrictions. Schaefer saw other motives.

"He tried to find a way to get me," Schaefer said.

As soon as Ehrlich took office and the dry weather broke, the water was turned back on. A spigot of goodwill has continued to flow.

When Ehrlich was consumed with the closing days of the legislative session in April, he asked Schaefer to serve as first lady Kendel Ehrlich's escort to the Miss USA Pageant in Baltimore. At a public meeting a few days later, Ehrlich playfully teased Schaefer about the first lady coming home "disheveled" from her "date" that night.

Addressing the municipal officials in Ocean City last month, Ehrlich spoke of other ways in which he has tried to charm the comptroller.

"You know, when I get in trouble with him, I use a cake," Ehrlich said. "If I've really screwed up badly, I produce a cake and the first lady. And if I think I've really upset him, in a way maybe that my predecessor upset him on a daily basis, I call the cake out, I get the first lady and I bring the kids, too."

After the laughter subsided, Ehrlich peered out into the crowd, looking for Schaefer.

"Is he laughing?" he asked. "I think all of you know that we are incredibly good friends. He is my partner, and he is someone I listen to. . . . I listen to him every day."

At times, such guidance seems to lead Ehrlich astray, such as the controversy that ensued last year after Schaefer complained about a Spanish-speaking clerk at a McDonald's. Ehrlich later defended Schaefer on the radio and called multiculturalism "crap" and "bunk," remarks that brought a rain of criticism.

Views differ on what the charm offensive has netted Ehrlich, but Schaefer seems to side with the governor far more often than not these days.

He has joined Ehrlich in berating House Speaker Michael E. Busch (D-Anne Arundel) for blocking legislation to legalize slot-machine gambling. Schaefer defended Ehrlich when the governor called a special session on medical malpractice without support from leading legislators.

And Schaefer is a frequent ally on the Board of Public Works, a three-member panel that approves state contracts and has become a forum for the comptroller to rant about illegal immigration, the spread of AIDS or any other topics on his mind.

Schaefer said that teaming with Ehrlich in advertisements is an example of bipartisan cooperation from which others in state and national government could benefit.

Baltimore Mayor Martin O'Malley, another Democrat with whom Schaefer has feuded, said Schaefer is a "valuable asset" for Ehrlich.

"He works very hard to give the Ehrlich administration cover," said O'Malley, who is a gubernatorial hopeful. "I think he probably prides himself at the degree to which he helps cover up the poor performance of the governor."

During a half-hour interview, Schaefer called Ehrlich "an honest guy" and "a very nice man" and said he is "as straight as an arrow" and "fundamentally does things I like."

But Schaefer turned coy when talking about next year's election. For the Democratic primary, he has endorsed Montgomery County Executive Douglas M. Duncan, whom he described him as "a good man, maybe the best of the lot."

Schaefer was quoted in the Washington Times several months ago as saying that if Ehrlich faced O'Malley in the general election, he would be forced to go to Bermuda to avoid taking sides.

"Puerto Rico," Schaefer said when asked about that. Pressed further, he cupped his hand around his ear, feigning a problem: "My hearing aide goes off once in a while."

Asked about his 1992 endorsement of Bush and the grief from fellow Democrats that followed, Schaefer explained that he and the then-president developed a friendship during a series of Bush visits to Maryland, including one in which Schaefer showed him some of Baltimore's urban ills. "He actually listened," Schaefer said.

Aides to Ehrlich said they have no expectation that Schaefer will endorse Ehrlich for reelection. Still, some analysts have argued that Schaefer's seeming validation of the governor sends the signal to conservative Democrats that, in essence, the governor is doing okay.

In several key suburban jurisdictions carried by Ehrlich in 2002 -- Baltimore, Carroll and Harford counties -- nearly 35 percent of voters cast ballots for both the Republican governor and the Democrat comptroller.

"Ehrlich can't win without those crossover voters," said Thomas F. Schaller, a political scientist at the University of Maryland, Baltimore County. "I think Bob Ehrlich will do everything in his power to keep William Donald Schaefer as happy as a dog on a meat truck for the next 16 months."

Schaefer, who plans to seek another term as comptroller next year, might have his own race with which to contend. He drew a primary challenge four years ago and could well face another next year.

Aides to Ehrlich said his affection for Schaefer is genuine.

"They're both sort of products of a blue-collar environment, worked like hell and were very successful," said Nelson Sabatini, who served as health secretary under Schaefer and Ehrlich. "Schaefer is a guy for whom friendship and loyalty comes before ideology. And honestly, there's not a chasm between them there, either."

Some differences have arisen. In April, Ehrlich pushed a one-cent reduction in the state property tax rate, which is set by the Board of Public Works. Schaefer helped vote it down.

Despite the defeat, Ehrlich scored points with Schaefer for his handling of the issue. Glendening would have twisted his arm to provide the deciding vote, Schaefer said. But that is not Ehrlich's style, he said.

"He didn't take me to task or bawl me out," Schaefer said. "He wouldn't do that."

Staff writer Matthew Mosk contributed to this report.

William Donald Schaefer, left, says Gov. Robert L. Ehrlich Jr. is "as straight as an arrow" and "fundamentally does things I like."William Donald Schaefer, left, reacts to then-Gov. Parris N. Glendening, with whom Schaefer feuded openly."We are incredibly good friends. He is my partner, and he is someone I listen to," Gov. Robert L. Ehrlich Jr., right, says of William Donald Schaefer.