Maryland Del. Micheal D. Smigiel Sr. is seen before debate on the same-sex marriage bill on Feb. 16, 2012, in Annapolis. (Mark Gail/The Washington Post)

Benefits for illegal immigrants. Same-sex marriage. Strict regulations on gun purchases.

Over the past two years, Maryland has enacted laws that represent a dramatic liberal shift, even for a state long dominated by Democrats.

Driving the progressive swing is Gov. Martin O’Malley (D) and the Maryland General Assembly, which now embraces legislation that it previously rejected. Emboldened by victories in statewide referendums, the governor and his allies have imposed tax increases, repealed the death penalty and approved a system to provide more than $1 billion in subsidies to a potential offshore wind farm.

Now, as the legislative session in Annapolis comes to an end, the state faces the question of whether Maryland is becoming a reliably liberal bastion like Massachusetts, California and Vermont.

Or has the state’s Democratic leadership moved too far to the left, potentially endangering incumbents at the polls in 2014?

Sen. Jamie B. Raskin (D-Montgomery) said the state has made historic breakthroughs, repairing long-standing social and moral injustices and taking necessary steps to protect the environment and reduce gun violence.

“It’s thrilling,” Raskin said. “We’ve had the death penalty for centuries. Gay people have been discriminated against forever. We’re vindicating people’s rights.”

But Republicans argue that Democratic leaders have alienated the electorate’s mainstream. Even as the General Assembly repealed the death penalty, a majority of state residents expressed support for executions in a Washington Post poll in February.

“We’re watching a huge overreach taking place,” said Senate Minority Leader E.J. Pipkin (R-Cecil). “The legislature is out of step with the constituency.”

Even moderate Democrats have expressed objections to much of the legislation, which included a proposal to decriminalize marijuana. Then there are the tax increases — on gasoline and the incomes of residents earning more than $100,000.

All of it has been too much for Del. John L. Bohanan Jr. (D-St. Mary’s), a moderate whose constituents ask him, “What were you people thinking?”

“It was just the pace of having so many in such a short period of time. It tends to choke the system,” he said. “It’s a lot for a state that has been pretty pragmatic.”

Del. Kevin Kelly (Allegany), a Democrat who described himself as “centrist-right,” opposed the gun-control legislation, the repeal of the death penalty and other liberal legislation.

His party’s leaders, he said, have “hijacked the Democratic Party. It’s gone left, left, left.”

Maryland has long been dominated by the Democratic Party, even though voters have, on occasion, supported such Republicans as Ronald Reagan and George H.W. Bush for president and Spiro Agnew and Robert L. Ehrlich Jr., who cast himself as a moderate, for governor.

Still, since the early 1980s, Maryland’s political dynamics have evolved as two of the state’s largest counties, Prince George’s and Montgomery, have grown and become more racially diverse, aligning them with Baltimore.

More recently, President Obama’s 2008 election set off a wave of progressive activism across the country, especially among young people. And polls have shown another recent shift: Americans have grown increasingly supportive of such issues as same-sex marriage.

The leftward drift in Maryland over the past generation may be connected to a drop in the percentage of registered Democrats and an increase in the percentage of unaffiliated voters, said Todd Eberly, an assistant professor of political science at St. Mary’s College.

Since the 1980s, he said, the percentage of registered Democrats has fallen from about 70 percent to 56 percent; independents have grown from about 1 percent to about 16 percent. As a result, he said, the Democrats voting in Maryland’s primaries tend to be more progressive.

“That will change the mix of folks who are in office,” he said. “So if you’re in the Senate, you see this and you say: ‘Our state is becoming more liberal. We’re going to be punished if we tack to the middle. We can feel more comfortable embracing a progressive agenda.”

Eberly added: “That doesn’t mean the electorate has changed dramatically. I don’t think the voters are there. I think there are a lot of Democrats convincing themselves that the voters are there.”

But Raskin said the results of statewide referendums last year suggest otherwise, at least on some issues.

Voters, he said, supported legalizing same-sex marriage in legislative districts where their state lawmakers opposed that initiative. Voters also approved the Dream Act, which granted qualified illegal immigrants in-state tuition rates at state universities.

“If anything,” Raskin said, “the people are more progressive than the politicians in our state.”

The first test of that assertion will come during next year’s elections.

Republicans say that they have identified Democratic incumbents who are vulnerable and that they’re prepared to portray them as disconnected from mainstream voters. State Republican leaders blame the leftward shift on the governor, saying that he is seeking to burnish his progressive credentials in anticipation of a presidential run in 2016.

“Martin O’Malley and the Democrats have a general hostility to taxpayers and small businesses,” said David Ferguson, executive director of the Maryland Republican Party. “They’re more concerned with setting up a progressive agenda as opposed to what’s best for taxpayers.”

But the governor and his allies say their main interest is addressing complex problems.

“Maryland’s often ahead of the curve in our country’s ongoing journey,” O’Malley said. “We’re growing more inclusive, more compassionate.”

Whatever the case, Democrats and Republicans agree on one thing: The political culture in Annapolis has grown more polarized, reflecting what has occurred nationally.

“We’ve become redder and bluer,” said Bohanan, who joined the General Assembly in 1999 and is an adviser to Rep. Steny H. Hoyer (D). “In a lot of ways, it reflects Washington, in that people are a lot less willing to compromise.’”

Del. Anthony J. O’Donnell (R-Calvert), the House minority leader, said that in the past, the Democrats were defined by two factions: progressives on one side, moderates and conservatives on the other.

“That would keep things from going too far to the left,” he said. “Now we have a bunch of leftists who dominate the General Assembly, and they’re making policy.”

Much of the opposition to progressive legislation has been voiced by representatives of Maryland’s rural areas, whose demographics have remained largely the same while those of the Baltimore and Washington suburbs have changed.

“There are two Marylands — the urban and the rural — and they have declared war on the rural areas,” Del. Michael D. Smigiel (R-Cecil) said in an interview, referring to progressives.

“I’m going to use the S-word,” he said, glancing at his chief of staff, who groaned and covered her eyes.

“Secession,” he said.

In Smigiel’s view, the Eastern Shore, which he represents, has more in common politically with Virginia, and Western Maryland is more like West Virginia.

Yet, for all his bluster, Smigiel stressed that he has worked with Democrats. Most recently, he voted for a medical marijuana bill. (“You’re going to deny a patient something that can help them because I don’t like the aesthetics of grandma toking on a joint?” he asked.)

In fact, Smigiel was a Democrat until about 2000, when “they left me and went too far left.” He became a Republican, and now he chairs the tea party caucus in Annapolis.

In politics, as the delegate well knows, things change.