Gov. Chris Christie, who has long resisted raising any taxes, has battled with Democratic leaders since early summer over raising New Jersey’s gas tax, reaching an impasse that brought hundreds of highway and transit projects to a standstill that lasted months.

But on Friday, a day after a fatal train crash in Hoboken focused attention on the troubled conditions of the state-run railroad, Mr. Christie, a Republican, finally gave way by accepting the first tax increase during his seven years in office. He said he had agreed to raise the gas tax by 23 cents a gallon to replenish the depleted Transportation Trust Fund, which the state uses to pay for improvements to rails, roads and bridges.

Mr. Christie, who has just over one year left in his second term, has prided himself on his refusal to raise taxes and promoted his record during his campaign to be the Republican presidential candidate. But he said he made an exception for the gas tax because the need to maintain the state’s transportation infrastructure was so critical.

“While I’m not authorizing any other tax increase during my time as governor,” he said, “I’m authorizing this one because of the importance of the Transportation Trust Fund, the tax fairness that we’ve accomplished together and the compromise we’ve reached, and because we need to responsibly finance this type of activity.”