The Ministry of Defence has awarded £3.2 billion of contracts to support the management of the UK's naval bases.
Babcock, which manages Devonport and Faslane, has been awarded a £2.6 billion deal, while BAE Systems, which manages HMNB Portsmouth, has been awarded a £600 million contract.
The deal will see the maintenance and repair of the Royal Navy's warships and submarines and sustain more than 7,500 UK jobs, the MoD said.
Defence Secretary Michael Fallon said: "This huge investment in our naval bases will directly sustain more than 7,500 jobs and skills across the UK and ensure that the Royal Navy's fleet of 56 warships and submarines are in the best possible condition and available for operations.
"Following the £3.5 billion 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.
"As a former minister for Portsmouth I know how important naval bases are for the local economies so I am delighted that these contracts have been awarded."
The contract will secure around 1,500 jobs at Faslane on the Clyde, up to 4,000 posts at HMNB Devonport and more than 2,000 at Portsmouth.
John Hudson, maritime managing director at BAE Systems, said: "This contract is an excellent example of our continued commitment to work collaboratively with the Royal Navy to increase the efficiency and effectiveness of operations at our Portsmouth business.
"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."
Commodore Jeremy Rigby, commander of Portsmouth Naval Base, said: "The contract will keep the base running at the highest standards and will ensure our ships are in the best possible condition and operating at the highest capability.
"This announcement comes at an exciting time for Portsmouth Naval Base as we prepare for the arrival of the Royal Navy's two new aircraft carriers - HMS Queen Elizabeth and HMS Prince of Wales."
A Babcock statement said: "This new contract reinforces Babcock's position as the UK's leading naval support business and enables us to continue to do what we do best - that is to provide continuity, reliability and increased value to our customer across the range of activities and services we deliver.
Mr Fallon said the "huge" contract would give long-term security to workers at Faslane.
He told BBC Radio Scotland's Good Morning Scotland: "There's no new jobs but I think it's very important to reassure those who are working on the Clyde, now that the referendum is over, that they will have that job security.
"This is one of the longest contracts we're placing and it's a huge contract, so it's confirmation that the Clyde will be one of our most important naval bases for years to come."
The announcement comes less than two weeks after the Scottish independence referendum, which saw Scots vote by 55% to 45% to stay in the United Kingdom.
With the SNP campaigning to remove Trident submarines from Scotland in the event of a vote for independence, pro-UK campaigners had warned voting Yes would put thousands of jobs at Faslane and the surrounding area under threat.
Mr Fallon said: "A majority voted to stay in the United Kingdom and all parts of the United Kingdom benefit from the nuclear deterrent. Those submarines keep us all safe - Scotland, England, Wales and Northern Ireland."
He stressed that in "an increasingly dangerous world" it would be "folly" for the UK to unilaterally disarm.
"Today's announcement shows the long-term commitment of the Government in London to securing the jobs there," he said.
"Scotland is a big part of the United Kingdom's defence and it will certainly stay that way."
First Sea Lord, Admiral Sir George Zambellas, said: "These significant contracts represent 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."
Shadow defence secretary Vernon Coaker MP said: " Labour fully supports the role played by the defence industry in creating jobs, promoting British exports and sustaining excellence in design and manufacturing. The defence industry makes a hugely significant contribution to our economy."
But he added: " 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."
The leader of Portsmouth City Council, Donna Jones, welcomed the announcement which she said would secure 2,000 jobs in the Hampshire city's naval base.
The Tory said: "I am delighted by today's announcement that the MoD has awarded a £600 million, five-year contract to BAE Systems. This is a really exciting time for the city and for the local economy as it means support for half of the Royal Navy's surface fleet on UK and global operations will be based right here in Portsmouth, securing 2,000 jobs in the naval base and many more in the supply chain.
"Today's announcement confirms Portsmouth as the home of the Royal Navy and shows enduring commitment to Portsmouth from both the MoD and BAE Systems. More than that, Government investment in infrastructure at the naval base will enable it to develop, securing its long-term future.
"Portsmouth continues to be enormously proud to be the home of the Royal Navy. Now we are looking forward with great excitement to a proud future, playing a central role in maintaining the fleet and preparing to welcome the Royal Navy's two new aircraft carriers - HMS Queen Elizabeth and HMS Prince of Wales - to their new home port."