TORONTO—Struggling BlackBerry Ltd. is preparing for deep staff cuts—up to 40% of its employees—by the end of the year, people familiar with the matter said.

The layoffs will cut across all departments and occur in waves, likely affecting several thousand workers, the people said. BlackBerry had 12,700 employees as of March, the last time it disclosed a total number.

The cuts come as the once dominant smartphone maker looks for ways to get a handle on costs and shrink its operations to better fit a world in which competitors such as Apple Inc. and Samsung Electronics Co. have eaten into its market share.

"Organizational moves will continue to occur to ensure we have the right people in the right roles to drive new opportunities in mobile computing," a BlackBerry spokesman said. He declined to comment on the 40% figure.

Smaller rounds of layoffs began earlier this summer, mostly from the sales and research-and-development divisions, and follow the loss of 5,000 jobs last year. Some employees have been told which of the new waves of cuts will affect them, one of the people said.