SAN FRANCISCO — Accusing Facebook of engaging in “unfair and deceptive” practices, the federal government on Tuesday announced a broad settlement that requires the company to respect the privacy wishes of its users and subjects it to regular privacy audits for the next 20 years.

The order, announced by the Federal Trade Commission in Washington, stems largely from changes that Facebook made to the way it handled its users’ information in December 2009. The commission contended that Facebook, without warning its users or seeking consent, made public information that users had deemed to be private on their Facebook pages.

The order also said that Facebook, which has more than 800 million users worldwide, in some cases had allowed advertisers to glean personally identifiable information when a Facebook user clicked on an advertisement on his or her Facebook page. The company has long maintained that it does not share personal data with advertisers.

And the order said that Facebook had shared user information with outside application developers, contrary to representations made to its users. And even after a Facebook user deleted an account, according to the F.T.C., the company still allowed access to photos and videos.