Microsoft’s video game and entertainment business was profitable for the first time in its history for the fiscal year ended June 30, the company said today.

The Entertainment & Devices Division reported an operating profit of $426 million for the fiscal year, compared to a loss of $1.9 billion a year earlier. The year ago results included a $1.1 billion write-off for the cost of replacing defective Xbox 360 consoles.

The company said it sold 1.3 million consoles during the fourth fiscal quarter ended June 30, bringing its total sold to date to 20 million units. The Xbox Live online game service has more than 12 million subscribers now — both free and paid — and Microsoft and its partners are selling 7.7 games for each console sold. Research and development costs were up $141 million, reflecting higher headcount costs.

The business includes PC games, Xbox 360, the Zune handheld music player, Microsoft Surface, and Windows Mobile software for cell phones. The division has never been profitable since its inauguration.

But not everything was good news. The division lost $188 million in the fourth fiscal quarter, compared to a profit in the previous third fiscal quarter of $89 million. Typically, the summer season is slow for video game sales. Microsoft still faces stiff competition from both Sony and Nintendo.

Sales for EDD in the fiscal year were $8.1 billion, up 34 percent from $6 billion a year ago.