New York City’s scores on state tests continued to inch up in 2015, though the number of students refusing to sit for the tests this year tripled.

Just over 35 percent of city students in grades three through eight passed the math exams, up one point over last year. In English, just over 30 percent of students passed, a two-point increase over last year that brought the city closer than ever to the state average, according to figures released Wednesday.

“For the second straight year and for the first year fully on our watch, New York City’s children have raised up their test scores in both math and English,” Mayor Bill de Blasio said.

The state also released final tallies of the number of students who opted out of the tests, after that movement saw dramatic growth over the last year. Twenty percent of eligible students statewide opted out of the tests, following waves of parent protests in many districts and the encouragement of the state teacher’s union.

In the city, the numbers were smaller. Only 1.8 percent of test-takers boycotted the math tests and 1.4 percent sat out the English tests — a tiny fraction of students, but a more than threefold increase over 2014’s percentage and a major increase over the roughly 350 students who opted out in 2013.

The city’s modest test-score gains were shared by every racial and ethnic group, though not every grade. Third, fourth, and eighth graders saw very slight declines in math scores, while all grade levels saw English scores rise. Still, fewer than one in five Hispanic and black students passed the exams, while more than half of white and Asian students did. The gaps were even wider for students who are still learning English.

[See what city schools saw the biggest gains and dips here.]

Still, the results were good news for Mayor de Blasio and Chancellor Carmen Fariña. 2015 was their first full school year at the helm of the city school system, and the third year since officials adjusted the tests to align with the Common Core standards, which sent scores tumbling in 2013. Earlier this year, city officials lost their fight with state lawmakers

“My guess is that the mayor and chancellor are breathing a sigh of relief, considering the kind of siege they’re under form some media and state policymakers,” said Aaron Pallas, a professor of education and sociology at Teachers College.

The state’s proficiency rates remain higher than New York City’s, though the city has nearly closed that gap in recent years.

Across the state, 38.1 percent of test-takers met the state’s proficiency bar in math this year, up from 36.2 percent last year. In English, 31.3 percent earned a proficient score, up from 30.6 percent last year, which state officials called “modest progress.”

Officials also released detailed demographic information about the students across the state who sat out the tests. Those students were more likely to be white, from wealthier districts, and were more likely not to have passed last year’s test, according to the state education department. In New York City, 39 percent of the students who opted out of the tests did not earn a passing score in 2014, the department said.

The fact that so many of the boycotting students did not pass last year’s tests suggests that this year’s statewide results could be slanted in some way. The large number of opt-outs in the state, but relatively few in the city, could also muddy city-state comparisons.

“There is no question that when you have approximately 20 percent of students not take the tests, the results would have variation based on that,” Elia said.

The city’s charter schools continued to outdo citywide proficiency rates in math, but lag in English. Proficiency rates at charter schools increased from 28 percent to 29.3 percent in English, and from 43.9 percent to 44.2 percent in math. Those rates have improved at a slower rate than the district-school averages.

See more city-specific data here, and the statewide data here.