A New York City high-school student who became an overnight sensation after a magazine article said he had made millions trading oil and gold stocks on Wall Street apologized Tuesday for making up the story.

New York Magazine acknowledged it had been “duped” by the teenager, Mohammed Islam, of Queens.

Mr. Islam, 17 years old and a senior at...