SAN FRANCISCO (Reuters) - A judge paved the way for federal authorities to close a California medical marijuana dispensary on Thursday that bills itself as the world's largest, dismissing a challenge by the city of Oakland to a federal crackdown targeting the facility, court papers showed.

Magistrate Judge Maria-Elena James wrote in a 10-page ruling that a local attorney had successfully argued the federal government was immune from Oakland's lawsuit under the Administrative Procedures Act, which sets out how U.S. agencies develop and issue regulations.

(Reporting by Ronnie Cohen, Writing by Alex Dobuzinskis; Editing by Cynthia Johnston)