Finally, Republicans in Maryland had something to brag about yesterday.

Ending more than three decades of futility, the GOP won the right to control a branch of state government for the first time since January 1969 -- six months before Neil Armstrong set foot on the moon -- as Rep. Robert L. Ehrlich won the governorship, trumping Lt. Gov. Kathleen Kennedy Townsend (D).

The Republicans' celebration was marred by Rep. Constance A. Morella's loss to Democratic challenger Christopher Van Hollen in the 8th Congressional District in one of the most expensive and competitive House contests in the nation. Morella, a seven-term incumbent, was unable to persuade enough Democrats and independents to back her in a district that has become increasingly hostile to the policies of the national Republican Party.

Republicans also lost their hold on Ehrlich's seat in the 2nd Congressional District, where Baltimore County Executive C.A. Dutch Ruppersberger defeated former representative Helen Delich Bentley's bid for a comeback.

But the GOP was happy to gloat over Ehrlich's victory, which even many of the party faithful considered unlikely last spring, when Townsend boasted immense advantages in name recognition, money and the polls.

Ehrlich overcame a huge disadvantage in party registration to win election. Democrats outnumber Republicans 2 to 1 statewide. He did it by casting himself as an independent-minded moderate in a liberal-leaning state, cloaking his Republican label and winning the favor of conservative Democrats.

GOP leaders, after many years of suffering at the polls, said the victory would give a permanent boost to their efforts to make Maryland a competitive two-party state for the first time since the 19th century.

"You cannot underestimate the significance of this," said Kevin Igoe, a Republican political consultant and former state party official. "An elected governor can do a tremendous amount to build a party, raise money and recruit candidates."

"You have to give a lot of credit to Bob Ehrlich personally," he added. "He rolled the dice, left a safe seat in Congress and went after someone who people thought would be very tough."

Independent analysts were more restrained. Donald F. Norris, a professor of policy sciences at the University of Maryland Baltimore County, said Ehrlich's victory was more the result of Democratic fecklessness. He called Townsend a weak candidate who frittered away advantages that should have paved a clear path to the governor's mansion.

"In this state, a Democrat should be able to win every single statewide election hands down," Norris said. "I'm sure this will give Republicans a lot of hope, but at least for the next decade or two, I think it's a false hope."

Regardless, Republicans salivated at the prospect of controlling the levers of power in the executive branch for the first time since Spiro T. Agnew moved out of the governor's mansion in January 1969 to become Richard M. Nixon's vice president.

The governor can immediately appoint people to more than 100 top jobs in state government. Over the course of a four-year term, the chief executive also usually is able to name 100 state judges and more than 5,000 people to advisory panels and commissions, from the Adoption Oversight Team to the Youth Camp Safety Advisory Council.

Ehrlich tried to turn the election into a referendum on the rule of Gov. Parris N. Glendening (D), whose approval ratings have plunged in the face of a projected $1.7 billion shortfall and his relationship with his deputy chief of staff, whom he married after leaving his wife.

"The voters in this state are just sick and tired of the Glendening administration," said Matthew Crenson, a political science professor at Johns Hopkins University. "It gave Republicans the best shot they've had in years. This may have been the best shot they ever had because Democrats stumbled up and down the line."

Townsend steered a wide berth from her political mentor, failing to appear with Glendening a single time on the campaign trail and stressing mild points of disagreement with her boss.

But Ehrlich wasted few opportunities to blame Townsend for the perceived failures of the administration. In his television advertisements, he ran perhaps more unflattering photos and video of Glendening than of Townsend herself.

Ehrlich did not have an official campaign slogan, but the catchphrase he repeated constantly was one that, according to exit polls, resonated heavily with voters: "It's time for a change."

On the campaign trail, Ehrlich usually did not specify what changes he intended to bring to Maryland, preferring to talk in generalities. "This election is about competence and leadership and change," he said Monday during a visit to Annapolis. "People are going to vote for a change. It's our time. It's our time to make history."

But beneath the rhetoric, the governor-elect has made no secret of his desire to rewrite a policy agenda in a state that has been wholly controlled by Democrats since the 1960s.

Among other pledges, he has promised to legalize slot-machine gambling in a partial solution for the state's budget woes. He also said he would end the state's moratorium on the death penalty, sign a ban on late-term abortions, toughen prosecution of gun crimes and build the intercounty connector highway in the Washington suburbs.

Whether Ehrlich will be able to accomplish those priorities depends on how well he responds to the state's record-setting budget shortfall, which he calls his most vexing challenge.

"The budget deficit is ugly to talk about," he said Monday. "It's just a fact that we can't pay our bills right now and it's going to take up a lot of my time during the first six months."