Harvard University finished the fiscal year in June with a $2.7 million surplus, driven by an increase in gifts and distributions from its endowment, the largest in higher education.

Total receipts from giving rose 46 percent to $1.2 billion, Harvard said in its annual report released today. Spending from the endowment increased 3 percent to $1.5 billion, it said.

The university rebounded from a $33.7 million deficit a year earlier. At the time, Harvard said it would seek to save money by curbing growth in employee benefits and centralizing purchases of services. While the surplus represents an improvement, it shouldn’t be a cause for excessive optimism, said Executive Vice President Katherine Lapp and Treasurer Paul Finnegan.

“We are heartened by the university’s marginal budgetary improvements, but continue to believe that Harvard, like many other colleges and universities, is facing ongoing foundational financial pressures,” Lapp and Finnegan said in the report.

The increase in revenue was offset by a 2 percent drop in research grants, Harvard said. Federal funding, which accounted for about three-fourths of the total, dropped 5 percent.

Harvard, based in Cambridge, Massachusetts, is in the middle of a $6.5 billion capital campaign, a record goal in higher education, that is set to end in 2018. The university said in September that it had collected commitments of more than $4.3 billion.

“The Harvard campaign has thus far exceeded initial expectations,” Lapp and Finnegan said. “The overall quality of philanthropy has been quite promising, in terms of alignment we are achieving between donors’ interests and the university’s core needs.”

The endowment’s value climbed to $36.4 billion as of June 30, the university reported in September. The fund’s investments returned 15.4 percent, the worst performance in the eight-member Ivy League.