Another political disaster was looming just around the corner, but Maryland Gov. Robert L. Ehrlich Jr. didn't see it coming. As he stood outside the gates of the governor's mansion Monday night, he predicted that a Senate committee was minutes away from endorsing one of his Cabinet nominees. "We've lobbied this in a personal way," he said.

Inside the Senate hearing room a few yards away, Ehrlich's aides were just as confident that Lynn Buhl, the governor's choice for secretary of the environment, would pass muster. One staff member brandished a committee roster and indicated that Buhl's approval was a done deal. "She's well on her way to confirmation," said former senator Martin G. Madden, one of Ehrlich's top advisers.

Moments later, however, senators astonished Ehrlich by voting 10 to 9 to reject Buhl, the first time the committee had turned down a Cabinet nominee in Maryland history. The decision made the governor and his staff look unprepared and unpolished, yet again.

It was the latest in a series of setbacks for Ehrlich, who took office seven weeks ago with high hopes for reforming government and restoring what he described as an atmosphere of collegiality to Annapolis.

But the first Republican to govern Maryland in 34 years has gotten off to a wobbly start. Despite his legislative experience in the General Assembly and Congress, his campaign to legalize slot machines has run into new obstacles almost daily. Other legislative priorities, such as charter schools and faith-based programs, are languishing. And his plan to balance the state's budget next year developed a $230 million hole last week.

It's not uncommon for new governors to stumble out of the gate. Gov. Parris N. Glendening (D), Ehrlich's predecessor, struggled to get a Democratic Senate to approve his Cabinet nominees, and his inaugural agenda was clouded by a scandal over a pension deal he had arranged from his previous job as Prince George's county executive.

Gov. William Donald Schaefer (D) had difficulty making the transition from mayor of Baltimore to Maryland's chief executive and was hampered by frosty relations with legislators.

Schaefer, now the state comptroller and a big fan of Ehrlich, sympathized with his struggles. He said Ehrlich made a mistake by failing to "clear" Buhl's appointment with the Senate leadership and stepped over the line when he accused House Speaker Michael E. Busch (D-Anne Arundel) of "playing the race card" in the debate over slots.

Ehrlich "is a good man. He's trying awfully hard," Schaefer said. "He might have walked a little heavy once in a while. I don't think he should have called Busch a racist.

"But that's things you have to learn," he added. "This is a testing block for him."

Ehrlich said criticism of his first several weeks on the job has been overblown but acknowledged some of the problems he is facing, including the possibility that Buhl's nomination could be torpedoed by the full Senate this week. "If we lose Lynn, you guys will appropriately report that we lost a big one," he said in an interview.

"In the short term, the headlines will be the headlines," he continued. "But we can't get caught up in the daily. We have to look at the endgame."

In some ways, Ehrlich's challenges are even greater than those of his predecessors, because he is a Republican tangling with an assembly ruled by Democrats. But many lawmakers said the governor's wounds have been largely self-inflicted, especially in regard to his ever-changing plan to legalize slots.

"Nobody did this to the governor but himself," said Sen. Thomas M. Middleton (D-Charles), chairman of the Senate Finance Committee and a slots foe. "It's a bill that's just been fumbled around with since Day One."

Ehrlich's first slots plan, introduced Jan. 30, fizzled within days after racetrack owners, horse owners and local governments all complained that it was unfair and impractical.

Even pro-slots lawmakers expressed frustration when Ehrlich's efforts to repair the bill dragged on for weeks. When he finally unveiled his reworked plan Wednesday, the merits of the bill were overshadowed by yet more gaffes.

The governor waited until 9 p.m. to make the details public at a hastily called news conference and told reporters that Senate President Thomas V. Mike Miller Jr. (D-Prince George's) was on his way. Miller didn't show up and said the next day that he had never been invited.

Worse, many lawmakers said they felt misled when Ehrlich and his staff briefed them on the new slots plan. The administration presented figures implying that the bulk of the gambling profits would go to public education, but barely mentioned a new wrinkle that would enable tracks to recover an extra $350 million a year in expenses.

"They've lost credibility by kind of pulling a fast one," said Del. Peter Franchot (D-Montgomery). "There's an old saying here that your word is your bond. And you don't ever want to damage that."

Ehrlich's allies blamed Democrats for causing most of his troubles. They said other mistakes were to be expected, given the challenges of putting together an entirely new administration in the space of a few weeks. Ehrlich was sworn in Jan. 15, one week into the assembly's 90-day legislative session.

"I think it's about typical for a first-term governor with a new team," said Kevin Igoe, a GOP political consultant. "You have a bunch of people in new jobs, and they're all trying to deal with a learning curve in the public spotlight."

Even Miller, usually a strongly partisan Democrat, has stood up for Ehrlich by minimizing the problems. "I don't blame the governor. He's got a very new staff and many of them are from Capitol Hill," Miller said. "We intend to work with him on the slots issue and on the Buhl issue in a nonpartisan fashion. I want to stress that."

Ehrlich has already indicated that he's willing to make adjustments and learn from his missteps.

For example, after the Senate panel voted to reject Buhl, Ehrlich's first reaction was to slap back at environmentalists who opposed her, yanking administration support from a bill to boost penalties on polluters. Ehrlich's top aides warned that the governor would pull out all the stops to save Buhl's nomination and that recalcitrant senators could expect to have their bills vetoed and their pet projects pulled from the state budget.

By week's end, however, Ehrlich conceded that environmentalists most likely had the votes to ditch the nomination. On Friday, he met with Sen. Brian E. Frosh (D-Montgomery), a leader in the fight against Buhl, and offered to cut a deal. Frosh said he would "think about it," and the two were expected to talk again this weekend.

If Ehrlich's difficulties continue, however, they could soon prove to be more than cosmetic. The assembly is scheduled to adjourn April 7, and many lawmakers are predicting that Ehrlich will be forced to extend the session because of his slow-moving agenda.

The governor also must quickly come up with a new plan to balance the budget. His revised slots bill left a $230 million gap in his proposed spending plan, and lawmakers are waiting for him to suggest a way to fill it, either by cutting spending or raising taxes. The assembly faces a March 31 deadline to balance the budget.

Ehrlich has threatened to slash spending if legislators don't legalize slots and has promised to veto any increases in the state sales or income tax. That has some Democrats concerned about gridlock.

"In the last 24 hours, we found out that we've got a $230 million hole in our budget, the track owners are making a ton of money and nobody can figure out the [administration's] numbers," Busch, the House speaker, said Thursday, one day after Ehrlich announced his new slots plan. "There can't be a legislator from either party who doesn't have concerns about all of this."

Although Ehrlich has continued to push his legislative agenda with confidence, he has occasionally displayed flashes of frustration.

As a small group of reporters followed him from a public reception to the State House on Friday afternoon, one asked whether his administration was "in meltdown." Ehrlich refused to answer and threatened to stop giving off-the-cuff interviews, saying that "the era of walking press conferences is over."

Less than 15 minutes later, however, Ehrlich gathered himself and summoned reporters to the governor's office for the first real interview he had granted in days.

"This week's been pretty good," he said. "So far, I'm reasonably pleased, but the big events have yet to play out."

Ehrlich, shown here with Lt. Gov. Michael S. Steele, said of his administration's difficulties: "In the short term, the headlines will be the headlines. But we can't get caught up in the daily. We have to look at the endgame."