New York City Mayor Bill de Blasio traveled to Albany to talk about the potential cuts in Gov. Andrew Cuomo’s proposed budget that would impact the Medicaid program and the City University of New York.

Instead, the mayor was grilled in a five-hour session by more than a half dozen state lawmakers on placing a property tax cap on New York City.

“The middle class is leaving in leaps and bounds,” said Republican Sen. Andrew Lanza of Staten Island. “I see that on Staten Island. This is going on long before you became mayor.”

The tax cap talk at the joint legislative hearing on the state budget and its impact on local governments was dovetailed by the GOP-led Senate approving, once again, a cap on property tax increases for New York City.

The hearing on Tuesday is part of “tin cup day” at the Capitol, in which local government officials — namely the mayors of the state’s largest cities — comment on the proposed state budget.

Every New York City mayor’s testimony looms large each year. De Blasio’s has been closely watched, given the public disagreements he has had with Cuomo and the animosity with Senate Republicans.

But the questions over the tax cap weren’t just limited to Senate Republicans. Democratic Sen. Tim Kennedy, as did Sen. Diane Savino, a member of the Independent Democratic Conference, quizzed the mayor on the tax cap.

Never mind that de Blasio insisted multiple times that he has no plans to draw more revenue from the tax by increasing the rate and that his proposed budget itself increases spending by less than 1 percent.

“I’m telling the people up front that I’m working everyday on property taxes,” de Blasio told Lanza. “One thing I’m adamant about is presenting budgets that do no include a property tax increase.”

The mayor, however, reiterated multiple times during the course of his testimony that he remains philosophically opposed to the measure.

“I don’t agree with it philosophically and practically as well,” he said.

The questioning on the tax cap proposal was so relentless that it clearly frustrated the mayor’s aides.

“Can someone explain to me why the City has spent four hours talking about property taxes today in Albany?” tweeted de Blasio spokeswoman Karen Hinton.

The state has had a cap on local and school property taxes in place since 2011. The measure limits levy increases to 2 percent or the rate of inflation, whichever is lower. This year the cap is unexpected to allow for an increase of less than 1 percent, leading to some school and local government officials to call for more leeway in the measure.

But supporters of the cap, including Cuomo, say the cap is working as it was intended to do: Limit the growth and cost of local government on property and homeowners.

During his testimony, de Blasio disagreed with the notion that middle class property owners were being driven out of the city.

“We are seeing a number of people coming into our city I would certainly not define as rich,” he said. “I don’t think it’s fair to say every net new resident we have is a wealthy person.”

The New York City cap approved by the Senate on Tuesday would allow for a supermajority on the city Council to override the measure in the event of an emergency, a provision de Blasio also questioned.

“A supermajority is not easy to come by and no one likes to increase property taxes,” he said.

At the same time, Republicans advanced an argument that Cuomo himself had initially made: The city should start to take on more costs associated with these programs. Cuomo has since said he is willing to work with the city to find efficiencies in spending.

Republican lawmakers questioned de Blasio’s overall argument regarding a cost shift proposed by the governor in the $154 billion budget for CUNY and Medicaid.

“The bottom line is that the city is awash in money right now,” said Sen. Cathy Young, a Republican who chairs the Senate’s Finance Committee.

At one point, Young even used an analogy that he been deployed by a Cuomo budget spokesman about an uncle financing a mortgage.

At the end of his testimony, de Blasio sought to steer the conversation back to the cost shift in Cuomo’s budget and a relative lack of public information.

“Overall,” de Blasio said, “there’s just a lot of elements of this budget that we don’t have the full facts on.”