But the opponents had no chance, as allies of the governor passed sweeping gun restrictions, the final victory in a series of triumphs that capped one of the most successful 2013 legislative seasons of any governor in the country. Besides gun control legislation, Mr. O’Malley coaxed a liberal wish list from the General Assembly session that ended Monday: repeal of the death penalty, a $1.7 billion subsidy for offshore wind turbines and a bump in the gasoline tax to pay for mass transit and roads. Republicans fumed that Mr. O’Malley had steered well to the left of Maryland residents’ concerns, and denounced his agenda as a punch list for a 2016 Democratic presidential primary campaign. Mr. O’Malley — largely unknown outside Maryland, though he is mentioned in presidential speculations alongside Govs. Andrew M. Cuomo of New York and John W. Hickenlooper of Colorado — said the bills were smart policy and in step with state residents. “I don’t think the relevant question for Maryland families is whether we’re moving left or right; it’s whether we’re moving forward or back,” he said in an interview. To voters under 35, who represent a generational shift in American politics, especially on social issues, “these are pretty mainstream things,” he added. In a relaxed mood a few days before the adjournment of the General Assembly, Mr. O’Malley, 50, offered a tour of the fine art in his office. He pointed out a Rembrandt Peale portrait of George Washington, whose distant eyes are the most arresting feature. “They have the look of a man who knows how the conversation is going to end before it begins,” Mr. O’Malley said. It was a comment that could apply as well to Mr. O’Malley, who is in his next-to-last year as a governor facing term limits. That he is looking ahead to a presidential campaign “is the worst-kept secret in Annapolis,” said Anthony J. O’Donnell, the Republican minority leader in the House of Delegates. Mr. O’Donnell added that the governor was “planting his flag as far to the left as possible” with left-leaning Democratic primary voters in mind. Mr. O’Malley would not confirm any such thing. He said he was flattered that people noticed “the tough things we’ve accomplished here.” “I haven’t put a whole lot of brain power or effort or time into 2016,” he said. His successes come on top of others a year ago, when lawmakers in the Democratic-controlled legislature approved same-sex marriage and in-state college tuition for illegal immigrants. After opponents forced both measures onto the state ballot in November, Mr. O’Malley campaigned hard for them, and voters upheld the changes — victories that provided political capital that allowed the governor to pass his even more ambitious agenda this year. But with lawmakers in Annapolis increasingly on the ideological wings of each party, it is an open question whether Mr. O’Malley has left Maryland residents behind. Protests against his gun restrictions, including an assault weapons ban and fingerprinting for handgun buyers, were the largest and most inflamed in memory. In a Washington Post poll last month, a plurality of Maryland residents, 48 percent to 41 percent, said the state was on the wrong track. A former mayor of Baltimore, who despised the city’s dark portrayal in the television show “The Wire,” Mr. O’Malley is not a traditional liberal. His arguments to abolish the death penalty were practical, not moralizing, in keeping with his reputation for shaping policy by analyzing data. He argued that capital punishment failed as a deterrent and did not reduce violent crime. Similarly, his defense of same-sex marriage and tuition breaks for illegal immigrants is an economic argument, aimed at attracting the well-educated and socially tolerant “creative class” to Maryland. “We believe that openness and inclusiveness are good for creating jobs and expanding opportunities,” he said. Mr. O’Malley has succeeded with a fiscal policy balanced between tax increases and spending cuts, of the sort President Obama has sought with less success in talks with Congressional Republicans. He has nearly wiped out a $1.7 billion structural deficit he inherited in the Maryland budget, partly by slowing the rise of spending. He won re-election in 2010 in part by pointing out that spending went up less in his administration than under the previous governor, a Republican. But Republicans denounce his tax increases, including on individual incomes above $100,000 — a definition of “high earner” that is lower than the $250,000 threshold Mr. Obama campaigned on during his re-election race. Critics say Maryland has chased entrepreneurs to lower-taxed Virginia. “Since 2007, we’ve lost 40,000 jobs in this state; we’ve lost 6,500 small businesses who have closed their doors to move across the border,” said Jeannie Haddaway-Riccio, the Republican minority whip in the legislature’s lower house. Mr. O’Malley has been called a rising star in the Democratic Party since he rode on the back of garbage trucks as mayor. But he has picked his battles with care. He decided not to challenge Kathleen Kennedy Townsend in the Democratic primary for governor in 2002. When she lost the general election, Mr. O’Malley had a clean shot at Annapolis four years later. He went on to lead the Democratic Governors Association, raising his national profile as a happy partisan warrior who attacked “the dinosaur wing of the Republican Party.” Strategists who have worked with him do not believe he will seek the presidency in 2016 if Hillary Rodham Clinton commits to the race. The governor is close to Mrs. Clinton, whom he supported in her unsuccessful 2008 primary campaign. A generation younger, he will presumably have many options when his term ends in 2014, including a run for the Senate or a cabinet position in a future Democratic administration. Mr. O’Malley pointed out that he had begun campaigning to overturn the state’s death penalty in 2007, his first year in office, long before Republicans in the General Assembly accused him of checking boxes for a presidential race. “These guys would be sorely pressed to say that that was some sort of appeal to the base in Keokuk, Iowa, or Manchester, N.H.,” he said. He turned to an aide, Teddy Davis, his director of strategic communications. “They still have the death penalty in New Hampshire, don’t they?” Mr. Davis said they did. “They had passed a repeal bill about 10 years ago. Governor Shaheen had vetoed it,” he said, referring to Jeanne Shaheen, a Democrat who is now one of the state’s senators. And how did an aide to Maryland’s governor know policy details in New Hampshire, which holds the first presidential primary? “Just learned my New Hampshire stuff,” said Mr. Davis, whom the governor recently hired to help with the next phase of his career.