SAN FRANCISCO — After a long legal battle plagued by procedural snags, Facebook has won a permanent injunction and $3 million in damages against spammer Power Ventures Inc. and its founder Steven Vachani.

U.S. District Judge Lucy Koh’s order, signed Wednesday, brings closure to a case the social networking company first filed in 2008, finding Power Ventures and its CEO liable for illegally accessing Facebook users’ data and sending more than 60,000 spam messages under the guise of being from Facebook itself.