R.J. Reynolds Tobacco Co. on Wednesday agreed to limit tobacco advertising in teen magazines, settling a lawsuit by California Attorney General Bill Lockyer.

The agreement, approved by San Diego Superior Court Judge Ronald S. Prager, ended a long battle over whether RJR, a unit of Reynolds American, violated terms of a 1998 settlement by pitching cigarettes to California teens through advertisements in magazines aimed at young readers.