More than 2,000 jobs are being secured at Portsmouth Naval Base
The Ministry of Defence has awarded £3.2bn of contracts to support the management of UK naval bases.
It said the deals would secure about 7,500 jobs at Devonport, Faslane and Portsmouth.
The money will also be used to maintain and repair the Royal Navy's warships and submarines for the next five years.
Defence Secretary Michael Fallon said the investment was the "second biggest defence contract placed by this Government".
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."
Babcock, which manages Faslane Naval Base on the Clyde and Devonport Naval Base in Plymouth, was awarded a £2.6bn contract while BAE Systems, which manages the Portsmouth Naval Base, was awarded a £600m contract.
Nuclear submarine HMS Astute is based at Faslane
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, former Minister for Portsmouth, 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."
The investment comes after 1,700 shipbuilding jobs were lost last year with the ending of all naval construction at Portsmouth.
'Value for money'
MoD chief of defence material Bernard Gray said: "The three naval bases in the UK play a vital role in the defence of this country and in the economic well-being of the regions in which they are located."
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".
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."
Shadow defence secretary Vernon Coaker 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 criticised the timing of the announcement, 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."