Maryland Gov. Martin O’Malley, bucking a trend in other states, signed off on legislation Tuesday that extends in-state tuition breaks to illegal immigrants at the state’s colleges and universities.

O’Malley’s signature sets up a showdown with opponents who have already started gathering signatures for a petition to try to repeal the law, which is slated to take effect this summer.

Supporters of the new law, including dozens of religious leaders, immigrant advocates, Democratic lawmakers and students, jammed the governor’s reception room at the State House in Annapolis to pose for photos and celebrate during the signing ceremony.

“We’ve got guts,” said Del. Ana Sol Gutierrez (D-Montgomery), a longtime advocate for the bill. “We were willing to go against the tide and stand up for something that is the right thing to do.”

The in-state tuition legislation was one of more than 200 bills the governor signed into law in a marathon session Tuesday. Among the others was a measure intended to create reliability standards for electric companies in response to extended power outages Pepco customers experienced last winter. Another creates a prescription-drug monitoring program aimed at curbing the state’s fastest growing drug problem.

In a boon to wine aficionados and vineyards in Maryland, O’Malley (D) also backed legislation that will allow residents to have their favorite bottles of wine shipped directly to their doorsteps.

It was the tuition bill, however, that had the most contentious road to passage and that will remain the source of political debate in the weeks ahead.

Sponsors had worked for years to pass legislation that would allow illegal-immigrant students to continue their education by paying lower in-state rates. Former Republican governor Robert L. Ehrlich Jr. (D) vetoed one version in 2003, and the measure this year was a tough sell even among some Democrats because of concerns about competition for a limited number of slots for residents.

In a compromise, sponsors rewrote the bill during the General Assembly session that ended last month to direct undocumented students initially to community colleges. Those who receive an associate’s degree are then eligible to transfer and pay in-state tuition at a four-year institution.

Students must have attended a Maryland high school for three years before graduating, must provide proof that their parents are state taxpayers and must express their intent to become a citizen.

After signing the bill, O’Malley said students whose families have been residents and paid taxes for many years “should not have additional barriers put up. It’s bad enough that we have a dysfunctional immigration system.”

Juan Lopez, a community college student from Hyattsville who attended the ceremony, said the change in law would make a four-year school affordable and allow him to “finally see my dream” of becoming a business administrator.

Maryland joins at least 10 other states, including California and New York, that allow illegal-immigrant students to pay in-state tuition rates. But the national trend is toward eliminating such breaks, according to the National Conference of State Legislatures. In Virginia, lawmakers have tried to go further, proposing to block illegal immigrants from attending state colleges.

Opponents of the new law in Maryland have until June 30 to collect the more than 55,000 signatures — or 3 percent of the number of votes cast in the last gubernatorial election — required to hold a statewide referendum on the law.

The measure is slated to take effect in July, allowing students to qualify for in-state tuition rates at community colleges starting in the fall. But if opponents are successful in collecting enough valid signatures, the law would be put on hold until the next general election in November 2012.

Del. Pat McDonough (R-Baltimore County), one of the lawmakers leading the opposition, said the petition effort is “ahead of schedule” and that he has been overwhelmed by the level of “passion and rage” from residents against the measure.

Opponents say they object to the state subsidizing the cost of education for illegal immigrants. In-state students, for instance, pay $8,400 in annual tuition at the University of Maryland compared to the $24,800 paid by out-of-state students.

McDonough acknowledged the challenge, however, of collecting tens of thousands of valid signatures in such a short period. Maryland’s law makes it difficult to qualify for the ballot. The last law petitioned to statewide referendum was a 1992 measure loosening restrictions on abortions.

“Will we hit the mark? I don’t know,” McDonough said. “The enthusiasm is there.”

The new laws governing utility reliability and wine shipments were among the most high-profile of the session. Following lengthy power outages last winter for Pepco customers, the governor and legislators successfully pushed for a new law O’Malley signed Tuesday that imposes a $25,000-a-day fine on electric utilities for violations of reliability standards. Regulators will be charged with crafting the standards, such as how quickly a company answers customer calls.

Del. Brian Feldman (D-Montgomery), who sponsored the bill in the House, called the standards a “critical first step” in improving the reliability of electric service.

Starting July 1, Maryland residents will be allowed to join those in the District, Virginia and 36 other jurisdictions in ordering bottles of wine by mail. The law permits residents to ship 18 cases per year, per household.

“It was just silly,” Sen. Jamie B. Raskin (D-Montgomery), one of the bill’s sponsors, said of the prohibition. “We’ve caught up with the rest of the country.”