After months of tense debate over financing for the Metropolitan Transportation Authority, state and city officials on Saturday announced a deal to pay for the authority’s ambitious plans to repair and expand the nation’s largest transit system, with New York City agreeing to sharply increase its contribution to the authority, a move state officials had demanded.

The agreement resolves a long and publicly contentious standoff between Gov. Andrew M. Cuomo and Mayor Bill de Blasio over whether the city should pay significantly more toward the five-year $29 billion capital plan — the authority’s largest ever — which will cover the cost of maintenance and improvements to the sprawling network of subways, buses and commuter rail lines.

Transportation officials and transit advocates had warned that the spending plan was vital to ensuring that the region’s public transit system could meet a growing list of challenges, including an aging subway system struggling to handle booming ridership amid rising delays and overcrowding. Under the agreement, Mr. Cuomo, a Democrat, pledged $8.3 billion in state funds to the authority, while the city would contribute $2.5 billion. The city had initially agreed to provide $657 million, but the de Blasio administration had recently held negotiations with representatives of the authority and the governor’s office over increasing the city’s contribution.

The deal included several conditions proposed by Mr. de Blasio, such as a promise by the state not to use money intended for the capital plan for any other purpose and giving the city say over projects in the five boroughs.