Pedestrians walk near BlackBerry’s headquarters in Waterloo, Ontario. BlackBerry said Friday it will lay off 4,500 employees.

TORONTO — BlackBerry said Friday that it will lay off 4,500 employees, or 40 percent of its global workforce, as it reports a nearly $1 billion second-quarter loss a week earlier than the results were expected.

Shares were halted pending the news and plunged as low as $8.01 when the stock reopened for trading. Shares regained some ground to close down 17 percent at $8.72.

BlackBerry had been scheduled to release earnings next week. But the Canadian company said late Friday afternoon that it expects to post a staggering loss of $950 million to $995 million for the quarter, including a massive $930 million to $960 million write down of the value of its inventory due to increasing competition. Revenue of $1.6 billion is only about half of the $3 billion that analysts expected, according to FactSet. The company’s expected adjusted loss of 47 cents to 51 cents per share falls far below the loss of 16 cents per share projected by Wall Street.

BlackBerry said it wants to slash operating costs in half by the first quarter of 2015 so cutting its global headcount to 7,000 total employees is necessary. The company let 5,000 people go last year.

“We are implementing the difficult, but necessary operational changes announced today to address our position in a maturing and more competitive industry, and to drive the company toward profitability,” Thorsten Heins, President and CEO of BlackBerry, said in a statement.

The BlackBerry, pioneered in 1999, was the dominant smartphone for on-the-go business people and other customers before Apple debuted the iPhone in 2007. Since then, BlackBerry Ltd. has been hammered by competition from the iPhone as well as Android-based rivals like Samsung.

In January, the company unveiled new phones running a revamped operating system called BlackBerry 10. The much-delayed touchscreen Z10 and keyboard Q10 were designed to better compete for customers and rejuvenate the brand. But the phones failed to turn the company around. BlackBerry’s market share continues to lag its rivals.

BlackBerry said last month that it would consider selling itself. The Waterloo, Ontario-based company reiterated Friday that a special committee of its board of directors continues to evaluate all options. It also seemed to say Friday that it would shift its focus back to competing mainly for the business customers most loyal to its brand. The company said it plans to focus on offering only two high-end devices and two entry-level handsets going forward, with emphasis on the enterprise market.

“Going forward, we plan to refocus our offering on our end-to-end solution of hardware, software and services for enterprises and the productive, professional end user,” said Heins. “This puts us squarely on target with the customers that helped build BlackBerry into the leading brand today for enterprise security, manageability and reliability.”

BGC analyst Colin Gillis said he couldn’t understand why BlackBerry would release the earnings late Friday, a week early. “Did you really need to do it 3:15 p.m. on a Friday? Couldn’t you have just waited a week?” Gillis said. “This is the quarter where the wheels really fell off the bus.”

The decline of the BlackBerry has come shockingly fast. Just five years ago, when the first iPhone came out, few thought it could threaten the BlackBerry. Now the very fate of the company is in question with some saying it is over for BlackBerry.

Blackberry, formerly known as RIM, was once Canada’s most valuable company with a market value of $83 billion in June 2008, but the stock has plummeted since, from over $140 share to less than $9. Its decline is evoking memories of Nortel, another Canadian tech giant, which ended up declaring bankruptcy in 2009.

“Our thoughts are with those who have lost their jobs at Blackberry, it is always a cause for concern for our Government,” Canadian Industry Minister James Moore said in a statement.