Hamrén, who will replace Lars Lagerbäck who resigned in October after Sweden failed to qualify for the 2010 World Cup, will however also stay on as Rosenborg coach until August 31, 2010.
Just last week, the Swedish association said talks with Rosenborg about signing Hamrén, 52, had broken down.
“After last week’s breakdown in the negotiations, the two sides have after a few days’ break reached an agreement on Erik Hamrén becoming Sweden’s coach,” it said in a statement.
Hamrén’s job specification will be limited to coaching the squad’s international matches until August 31 after which he will become a full-time coach.
“We are very happy and proud to sign Erik Hamrén as coach. For the Swedish Football Association, this is a long-term solution,” team president Lars-Åke Lagrell said.
Hamrén has coached Rosenborg since June 2008 and transformed the Norwegian club, blazing to the title with just one defeat.
“To become the national squad coach for one’s own country has been a big dream for me, and I’m very grateful that Rosenborg has given me this opportunity,” he said.
Hamrén will make his first appearance with Sweden in an away match against Italy on November 18.