The Post Office network is to get £370m in new funding, the government has announced.
About £160m of the money will be used to protect village community branches, Business Secretary Greg Clark said.
The three-year funding deal, running from next April, comes as the Post Office announced it had moved into profit for the first time in 16 years.
Unions dismissed claims the investment would save the network, arguing that it was just “managing decline”.
In addition to the money for village branches, some £210m will be used to modernise services and technology.
The government said it had invested more than £2bn since 2010, leaving a network of around 11,600 branches, extended opening hours and thousands of branches open on a Sunday.
Mr Clark said the Post Office, run by an independent board, was “at the heart of communities across the UK, with millions of customers and small businesses relying on their local branch every day to access a wide range of important services”.
He said: “With the network at its most stable in decades, this £370m of government funding will ensure it can continue to modernise and bring further benefits to customers across the UK.”
Alongside the announcement, the Post Office revealed that it made £13m in the last financial year.
Paula Vennells, its chief executive, described this as “a major milestone in the Post Office’s journey to a sustainable and successful business”.
She added that “we are better placed than ever to embrace the future”.
But a spokesman for the Communication Workers Union said the government “was dressing up” the announcement as good news.
In reality, the network was facing a funding cut, and the turnaround in profits was achieved from branch closures and thousands of job cuts, the CWU said.
Brian Scott, of the Unite union, said the Post Office lacked a “coherent strategy for the future” and said that profits were being achieved through a “slash-and-burn approach”.