"I'm not sure that William Donald Schaefer could ever fully align himself with a successor. It was his baby. He was passionate about it," Mr. Wasserman said.

Well into the Ehrlich administration, Mr. Schaefer also retained his ability to generate controversy — and to draw the governor into it.

In 2004, Mr. Schaefer stunned many at a public works board meeting by launching into a denunciation of immigrants who couldn't speak English well and the businesses that employed them. It was a tirade prompted by a stop that morning at a McDonald's where an employee's poor language skills delayed his breakfast order.

"I don't want to adjust to another language," he complained. "The people who come here should become part of America, become Americanized and speak the language."

Mr. Schaefer's remarks created a furor that was compounded a few days later when Mr. Ehrlich came to his defense. Going a step farther than the comptroller, the governor proclaimed that multiculturalism is "crap."

The two officials became the target of harsh criticism from advocates for immigrant groups and liberal-leaning figures. But for many voters, Mr. Ehrlich and Mr. Schaefer were merely expressing what they themselves were thinking.

Mr. Schaefer's behavior became an issue again in 2006, when he conspicuously ogled a 24-year-old female aide to Mr. Ehrlich at a public works board meeting and told her to "walk again."

"She's a pretty little girl," Mr. Schaefer told reporters. She "ought to be damn happy that I observed her going out the door."

A strongly negative public reaction to the incident, captured on television and seen by a national audience, showed that Marylanders were becoming less forgiving of the octogenarian comptroller's antics. After several days of stubbornly defending his actions, Mr. Schaefer sent the embarrassed young woman a vaguely worded, handwritten letter half-apologizing for his behavior.

While Mr. Schaefer continued to be personally supportive of Mr. Ehrlich, he remained stubbornly independent. He openly questioned the governor's handling of the Port of Baltimore and opposed him on some contract awards.

On one occasion in March 2006, Mr. Schaefer launched into a tirade over rising electric rates in which he called Mr. Ehrlich about the vilest name in his lexicon: "Glendening Junior."

The next month Mr. Schaefer complimented Mr. Ehrlich's handling of the issue and publicly apologized to the governor for calling him a "bad name."

"That's one of my idiosyncrasies," Mr. Schaefer said.

Ms. Kopp said there were times when she wanted to shake Mr. Schaefer and demand to know why he was acting the way he did. But she said he was also a mentor and loyal friend.

"He was one of the kindest and most supportive people I've dealt with in Annapolis," she said. "I know that's not his image, but it's the truth."

By the time he was approaching his last campaign, polls showed Mr. Schaefer's popularity on the wane among Democratic voters. The seeming vulnerability emboldened Del. Peter Franchot, an energetic and highly partisan Democrat from Montgomery County, to launch a primary challenge. Janet S. Owens, the Anne Arundel county executive, would also jump into the race.

Mr. Schaefer's last campaign was a strange, barely visible ramble marked by sparsely attended events and little interaction with the news media.

Late in the campaign, with his political peril becoming clear, he released a radio commercial halfheartedly apologizing if his remarks had offended anyone. But he almost immediately undercut his own words by launching an attack on Ms. Owens' physical appearance, deriding her as "Mother Hubbard" and calling her fat.

As Mr. Schaefer and Ms. Owens exchanged bitter words, Mr. Franchot mobilized liberal-leaning Democratic activists, garnered key newspaper endorsements and managed a narrow victory over Ms. Owens.

Mr. Schaefer finished third, with just under 30 percent of the vote.