The deal was the result of successful lobbying by the people of Hamburg, Germany's second biggest city and main port. They voted for a return of Vattenfall's grid into public ownership last September.
In the referendum, 50.9 percent voted in favour of the power-grid sale, while the Social Democrat mayor and the Christian Democratic Union, Germany's largest party, had campaigned for a no-vote.
"We regret to have to sell the electricity network business, but will continue to have a strong presence in the region and work closely as a partner to the city of Hamburg," said Tuomo Hatakka, head of Vattenfall's Continental Europe region.
The value of the transaction is expected to be about 400 million Euros.
Vattenfall, which expanded its operations in Germany in 2010, has already seen the closure of two of its nuclear reactors in the country following Germany's policy decision in 2011 to exit nuclear power, writes AFP. Vattenfall's licence to run Berlin's power grid expires this year.