Image copyright Getty Images Image caption The job cuts are the deepest in the firm's 39-year history

Microsoft is to cut up to 18,000 jobs marking the deepest cuts in the technology firm's 39-year history.

The bulk of the cuts, around 12,500, will be in its phone unit Nokia, which Microsoft bought in April, the firm said.

Microsoft pledged to cut $600m (£350.8m) per year in costs within 18 months of closing the acquisition.

The cuts are much more severe than the 6,000 initially expected.

The firm employs 127,000 globally, including 3,500 staff in the UK.

Microsoft declined to say how many jobs in the UK would be cut as a result of the changes.

Chief executive officer Satya Nadella, who took the helm in February, wants the firm to shift its focus away from software to online services, apps and devices.

"Making these decisions to change are difficult, but necessary," Mr Nadella wrote in the announcement to staff.

The firm said it also planned to have fewer layers of management "to accelerate the flow of information and decision making."

Microsoft said staff affected by the job cuts would be notified over the next six months, and they would be "fully completed" by the the end of June next year.

In total it said the cuts, including severance pay, would cost it between $1.1bn to $1.6bn (£643m to £935m) over the next year.

Daniel Ives, an analyst at FBR Capital Markets & Co, told the BBC that although it was painful the cuts would "put the company in a much better situation for the coming years".

"It's been a decade of pain and now you finally have a chief executive that's going to be pro-active rather than re-active and put Microsoft in a situation that they could be a successful mobile and cloud player," he added.

Analysis, BBC technology reporter Joe Miller:

Satya Nadella has only held the reins at Microsoft for five months, but the Nietzsche-quoting chief executive is determined to shake-up the once dominant firm.

Microsoft's operating systems, which used to be the outright leader in personal computing, are now only used on 14% of devices, if you take into account smartphones and tablets.

Adapting to what Mr Nadella calls a "mobile-first, cloud-first" world was the driving force behind Microsoft's $7.2bn acquisition of Nokia's mobile handset division earlier this year, and the job cuts announced on Thursday, many of which involve Nokia departments, are designed to "simplify" this process.

The tech industry, Mr Nadella said in an email to employees last week, "does not respect tradition, it only respects innovation," and his hope is that a focus on productivity tools such as Skype and personal assistant Cortana will bring back this said respect.

Perhaps it will, but not, it seems, without casualties.

Last week, Mr Nadella rebranded the firm as "the productivity and platform company for the mobile-first and cloud-first world."

The cuts are aimed at helping Microsoft better compete with rivals including Google and Apple.

The last significant job cuts at the firm were in early 2009, when previous chief executive Steve Ballmer axed 5,800 staff.