Djurgarden, champions in 2002 and 2003, drew 0-0 at Orgryte, which was enough to put the Stockholm club four points ahead of second-placed Gothenburg with one match left.
"I think we've been the best team this year, we've scored the most goals," said Djurgarden coach Kjell Jonevret. "No other club has come up to our level, so we deserve the title."
"Right now it's a bit of a shock (but) we've been in the lead for 14 rounds now. That we grab the gold now is not that much to talk about."
The Swedish Cup holders have a chance to clinch a domestic double as they face Atvidarberg in the final on October 29.
Hosts Hammarby had trailed 2-1
But Petter Andersson equalised in the 85th minute and then set up the winner for Erik Johansson in the 90th, handing Djurgarden their 11th Swedish championship.
"We were getting ready for some mad attacking when Hammarby made it 2-2," Jonevret said. "Then they made it 3-2 and 0-0 was a decent result."
Winning the title means Djurgarden will go into the second qualifying round of next season's Champions League.
"This is the fifth year in a row that we'll be in Europe, we'll do better this time than we did last year."
Djurgarden lost on away goals to Ireland's Cork City in this year's UEFA Cup after their second qualifying round match finished 1-1 on aggregate.