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...