BlackBerry Ltd. reached an agreement to sell most of its real-estate holdings in Canada, to help the struggling smartphone maker shore up cash for its turnaround plan.

BlackBerry will sell more than 3 million square feet of space, plus vacant property, and lease back some of it in a transaction expected to close by the end of May, according to a statement. The Waterloo, Ontario-based company didn’t disclose terms of the agreement, nor name the buyer. CBRE Ltd. advised BlackBerry on the deal.

The sale may raise as much as C$550 million ($491 million), based on sales prices for previous BlackBerry buildings and leaseback agreements, Ted Davis, a property broker with Avison Young Inc. who specializes in southwestern Ontario, has said.

Chief Executive Officer John Chen is returning the company to its roots as a maker of devices for business users, offering phones with physical keyboards after a shift to touch-screen devices failed to catch on with consumers. He struck a deal in December with Foxconn Technology Group to outsource phone production to save money, and expects BlackBerry to stop losing cash by the end of the fiscal year that concludes in March 2015.

The property deal “will help us move toward our goal of continued operational efficiency,” Chen said in the statement.

BlackBerry, which announced its intention to sell the property two months ago, remains committed to having “a strong presence” in Canada, said Chen, who is based in California. “We continue to consider Waterloo home to our global headquarters.”

BlackBerry rose 1.9 percent to $9.60 at 9:32 a.m. in New York. The shares had added 27 percent this year through yesterday.