SAN FRANCISCO — Facebook Inc. has turned to the federal courts in hopes of stopping a user the company’s lawyers at Perkins Coie say has scammed it out of hundreds of thousands in advertising dollars.

Martin Grunin purchased advertising accounts using the names and accounts of legitimate marketing companies he never worked for, according to a complaint filed in San Francisco federal court Tuesday. He sold some of his Facebook advertising accounts online to the highest bidder, according to Perkins Coie attorneys Judith Jennison and Joseph Cutler­. Others he used to post sexually explicit ads for casual-dating services.