TOKYO — Nissan Motor Co. posted a net profit of ¥3.76 billion ($24 million) for the April-June quarter, its first quarterly profit in two years, the automaker said Monday.

The result marks a sharp reversal from a net loss of ¥115.8 billion in the same period a year earlier.

Nissan credited the turnaround to aggressive cost-cutting, including the sale of its headquarters building, reductions in manufacturing sites and cuts to global production capacity. Those moves were designed to align output with demand.

The company said it is maintaining its full-year financial forecast, signaling confidence in a sustained recovery.

The S&P 500 rose 1.5 percent to 7,601 and the Nasdaq climbed 2.1 percent to 25,914 on Monday.

Shareholders will watch upcoming earnings reports to determine whether Nissan can sustain the discipline that drove this quarter's results.