HAVING BALKED at raising gas taxes a year ago, Maryland reversed course this year — a victory of practicality over poll-driven politics that will pay dividends for years. With impressive speed, lawmakers adopted the first gas-tax hike in a generation in response to a coordinated push by Gov. Martin O’Malley and the two top leaders of the General Assembly, all Democrats.

The legislation is expected to raise about $4.4 billion for new transportation projects and maintenance over six years, a relatively modest amount, given the need. Still, if lawmakers had not acted, the state was on course to run out of funds by 2017 for all but routine upkeep on highways, bridges and rails.

As Mr. O’Malley acknowledged, Maryland was spurred to action in part by Virginia, where an even larger gas-tax increase, the first in more than a quarter-century, was enacted a few weeks earlier by a Republican-dominated legislature with the support of Gov. Robert F. McDonnell, also a Republican. In fact, as the Wall Street Journal reported, some 17 states, including solidly Republican ones, are either implementing or seriously considering higher levies on gas this year, in many cases after having postponed doing so because of voter opposition during and immediately after the recession.

Somehow Republicans in Annapolis did not get the word about the growing bipartisan accord nationally on the need to modernize transportation infrastructure — and the consensus that the gasoline tax is the most sensible way to raise the money. Practically every Republican lawmaker in both houses of the General Assembly voted against Mr. O’Malley’s gas-tax legislation.

That display of uniform obstinacy goes a long way toward explaining why the GOP has become marginalized and all but irrelevant in Maryland politics. Until the party produces leaders who can fashion realistic solutions to pressing problems such as transportation, Maryland will remain a one-party state, to the detriment of voters.

Republicans (joined by a few Democrats) argued that higher gas taxes would force poor rural residents to subsidize urban transit projects they’d never use, and they attacked the gas tax generally as regressive. In fact, the gas tax is a user fee, a means of ensuring that those who benefit from transportation infrastructure pay for it. As with most transportation projects — and most government programs, for that matter — not every resident of the state will benefit equally. But we don’t hear rural Marylanders complaining that richer residents of the state subsidize poorer school districts.

As in Virginia, revenue from the per-gallon gas tax in Maryland was stagnant, impervious to inflation and soaring construction costs. The legislation in both states corrects that by indexing the gas tax to inflation; it will now move in line with prices, like the sales tax.

Republican leaders in Annapolis blasted that as unfair. But the alternative was an ever-shrinking budget to fulfill one of state government’s most basic obligations: providing an adequate transportation infrastructure that will allow the state to remain economically competitive.