Rolls-Royce has pledged to protect 7,000 engineering jobs in the east Midlands as part of a £150m investment, its largest single outlay in the UK for more than a decade.

The engineering firm struck a deal with trade unions that will safeguard work for nearly a third of its 22,300-strong UK workforce for five years, as it prepares to double the number of engines it builds.

Rolls-Royce will ditch plans to close a precision machining facility in Derby, saving 150 jobs that were at risk, as well as creating 200 new positions by building a new testing facility for jet engines.

Of the £150m planned investment, £90m will be spent on building the “testbed”, Rolls-Royce’s sixth in Derby, where it puts engines destined for commercial jets through their paces.

The testbed will be large enough for Rolls-Royce’s new range of UltraFan engines, which are bigger and designed to be more fuel efficient than previous models.

It will also use the site to test the Trent 900, which powers the Airbus A380 “superjumbo”; the Trent 1000, used on Boeing’s “Dreamliner”; and the Trent XWB, which powers the Airbus A350 and has become the world’s fastest-selling engine.

The overall plan also includes investment in Rolls-Royce’s large engine maintenance, repair and overhaul facility, as well as the Hucknall and Annesley sites in Nottinghamshire.

The trade union Unite, which had been campaigning for extra investment from Rolls-Royce, said the plan “effectively secures the manufacturing base of Roll-Royce in the UK for the next 20 years, along with 7,000 high-quality jobs”.

The Unite general secretary, Len McCluskey, said: “This is great news for a world-beating workforce making world-class engines and testament to the hard work of Unite’s shop stewards and members.

“It is a good day for British manufacturing that must not be undone by a botched Brexit.

“The government must now play its part by pursuing a ‘jobs first’ Brexit and securing tariff-free access to the single market and customs union. A failure to do so risks future investment and decent high quality manufacturing jobs.”

Rolls-Royce’s commitment to protecting UK jobs comes just four months after it reported a £4.6bn pre-tax loss, the largest in its history, due to the impact of Brexit on sterling and the cost of settling corruption charges.

The business secretary, Greg Clark, said the investment “underpins the critical role the UK plays within the global aerospace sector”.

“The UK and Rolls-Royce are known throughout the world as pioneers of advanced engineering technology,” he added.