The Ministry of Defence has awarded contracts worth £3.2bn for the upkeep of the Royal Navy's fleet.
It said the deal would secure about 7,500 jobs at the UK's naval bases at Devonport, Faslane and Portsmouth.
Defence Secretary Michael Fallon said it was the “second biggest defence contract placed by this government”.
Labour criticised the government for announcing “existing and previously proposed contracts” during the Tory party conference.
The money will be spent on maintaining and repairing the Royal Navy's 56 warships and submarines.
Babcock, which manages Faslane Naval Base on the Clyde and Devonport Naval Base in Plymouth, was given a £2.6bn contract while the company that runs the Portsmouth Naval Base, BAE Systems, was awarded one worth £600m.
First Sea Lord Admiral Sir George Zambellas said they were “significant contracts” which represented “a strategic investment in the Royal Navy's essential infrastructure”.
“Without the stalwart and tireless support provided by each of the three naval bases ashore, the ships and submarines of the Royal Navy would not be able to deploy as a credible, strategic and global presence at sea.”
Up to 4,000 jobs at Devonport, more than 2,000 at Portsmouth and about 1,500 at Faslane – home to the UK's fleet of Trident nuclear submarines – will be secured.
Mr Fallon said: “Following the £3.5bn Scout armoured vehicle contract, this is the second biggest defence contract placed by this government and reflects our commitment to giving our armed forces what they need to keep Britain safe.”
Speaking to BBC Radio Scotland about the Faslane contract, he accepted that no new jobs were being created, but added: “I think it's very important to reassure those who are working on the Clyde, now that the referendum [on Scottish independence] is over, that they will have that job security.”
SNP defence spokesman Angus Robertson criticised the government for using Faslane for nuclear submarines and said his party wanted a secure future for the facility as a conventional naval base.
“Faslane should be a 21st century facility for its naval defence needs now and in the future – not a nuclear dumping ground,” he said.
The MoD contracts come after 1,700 shipbuilding jobs were lost last year with the ending of all naval construction at Portsmouth.
The MoD said the deals brought five existing contracts under one framework, which it said “represents excellent value for money for the MoD and the UK taxpayer with over £350m of savings secured”.
Shadow defence secretary Vernon Coaker said Labour fully supported the role played by the defence industry in creating jobs.
But he criticised the timing of the announcement, coming as it does during the Conservative party conference, saying: “David Cameron's botched procurement plans caused uncertainty for industry and defence workers across the country.
“Workers at Devonport, Faslane and Portsmouth will welcome the fact that existing and previously proposed contracts will continue there. But what we need are long-term decisions based on the country's defence needs, not cynically-timed announcements and made-up news for political ends.”
John Hudson, maritime managing director at BAE Systems, said of the Portsmouth investment: “This is an exciting time for everyone at the naval base.
“Working together, we will prepare the naval base for the arrival of the UK's Queen Elizabeth Class aircraft carriers and continue to use our ship design and build knowledge to support the surface fleet in service.”
Babcock said: “This new contract enables us to continue to do what we do best – that is to provide continuity, reliability and increased value across the range of activities and services we deliver.”