The funding is a "significant step to rebuilding the rail system New Zealanders deserve".
The Government-owned KiwiRail was one of the major winners in today's Budget, receiving a $1 billion boost.
A third of that has been allocated from the Provincial Growth Fund and represents the biggest single spend from the fund to date.
Speaking to media inside today's Budget lockup, Deputy Prime Minister Winston Peters said the spending means "rail is back on track".
Peters, who is also the Minister of State Owned Enterprises, said supporting the future of KiwiRail was critical, as it is a "valued" part of New Zealand's transport network.
"This funding will make KiwiRail more resilient and reliable through substantial investment in rail infrastructure, purchasing new locomotives and wagons, and beginning the process to replace the Interislander ferries."
Of the $1b – which has been allocated over two years – $375 million is for new wagons and locomotives and $331m has been earmarked for buying new tracks and supporting other infrastructure.
Some $35m will be spent on replacing the Interislander ferries with new rail-enabled ships.
"After 155 years of rail in New Zealand, the historic misstep of privatisation and the managed decline of the past decade, securing the assets for the future is especially gratifying," Peters said.
He said today's spending plan represented a "significant step to rebuilding the rail system New Zealanders deserve".
Transport Minister Phil Twyford said today's funding for rail was the first step in rebuilding it as the "backbone of a sustainable 21st-century transport network".
He confirmed a long-term national rail plan would be developed later this year.
"Our goal is to have a stronger rail network that sees more freight moved by rail and fewer heavy trucks on our roads, as well as better public transport options to give commuters choice."
He said the previous government had taken a hands-off approach and left rail in a state of managed decline.
Twyford said further investment in KiwiRail would be considered in Budget 2020.
Other capital investment announced in today's Budget includes $1.7b to fix hospitals over the next two years.
A 10-year investment in schools, starting with $287m this year for the first wave, and a further $913m for another four waves of spending was also announced.