REDMOND, Wash. — Microsoft has announced the biggest layoffs in its history, saying it will cut up to 18,000 jobs or 14 percent of its staff as it works to cut down on management layers and integrate the Nokia cellphone business it bought in April.

The news sent Microsoft’s stock up 3 percent in morning trading.

Although the job cuts had been expected, the extent of them was a surprise. It’s the boldest move by CEO Satya Nadella since he took the reins from Steve Ballmer in February. In a public email to employees Thursday, he said the changes were needed for the company to “become more agile and move faster.”

Of the job cuts, about 12,500 professional and factory jobs will be cut. Microsoft expects charges of $1.1 billion to $1.6 billion over the next four quarters, which includes $750 million to $800 million for severance and related benefit costs.

FBR Capital Markets analyst Daniel Ives said the cuts were about double what Wall Street was expecting.

But he said they were necessary to streamline operations and clean up a bloated management structure.

“Microsoft needs to be a ‘leaner and meaner’ technology giant over the coming years in order to strike the right balance of growth and profitability around its cloud and mobile endeavors.”

The move dwarfs Microsoft’s previous biggest job cut, when it cut about 5,800 jobs in 2009. That was the company’s first ever widespread layoff.

Microsoft has been shifting its focus from traditional PC software to cloud computing and cloud-based products like its Office 365 productivity software.

With its $7.3 billion acquisition of Nokia’s cellphone business, Microsoft has been is seeking to meld its software and hardware business into a cohesive package, similar to rival Apple. In a letter to employees, Executive Vice President Stephen Elop said the company will drive sales of its Windows Phone by targeting the lower-price smartphone market with its Lumia devices. It also plans to develop more products for the higher-end smartphone segment.

In a blog post a week ago, Nadella hinted at the move, saying Microsoft had to “change and evolve” its culture for the “mobile-first and cloud-first world.”

Nadella said Thursday that he would give more details when Redmond, Wash.-based Microsoft reports fiscal 2014 results on Tuesday.

Shares of Microsoft rose $1.27, or 3 percent to $45.35 in premarket trading. The stock is up nearly 18 percent since the beginning of the year.