The Swedish power company currently owns 74.9% of the district heating system while the city holds a 25.1% minority stake.
The buyout includes the heating grid and the Tiefstack and Wedel plants.
Communal or district heating networks generate heat in central plants and pump hot water into homes via underground cables.
The confirmation comes after a 2013 referendum in which voters asked Hamburg to take ownership of gas, power and district heating systems, following which the city and Vattenfall signed an option contract to purchase the company’s stake in the project.
Vattenfall said the contractually agreed minimum price for buying the heat business in Hamburg is €950 million (£830m) but the actual payment to be made by the city will amount to €625 million (£546m), adjusted for the share paid in 2012.
The transaction is expected to be completed by January 2019.
Tuomo Hatakka, Senior Vice President Business Area Heat at Vattenfall said: “We make no secret of the fact we would have liked to continue to work together with the city on the conversion of the district heating system towards environmentally friendly heat generation and increasingly integrate renewable energy sources.
“However, we respect the decision and will do everything we can to ensure a smooth transition of the company to the city. To continue as a minority shareholder was not an option for Vattenfall.”