Jay-Z’s surprise outdoor performance for a taping of the “Late Show with David Letterman” yesterday was moved to the studio’s rooftop, where it was unseen and unheard by all except for about 100 fans.

As The Post first reported last Friday, the Mayor’s Office of Film, Theatre and Broadcasting denied Jay-Z and CBS a permit to hold the show on the Ed Sullivan Theater’s marquee — where it would have attracted a crowd of thousands — after word leaked out.

Instead, Jay-Z and Eminem performed on the rooftop for just 100 fans who had entered contests on Facebook and Twitter.

“They don’t want a riot so they always shelter the big guys,” said one of the lighting technicians. “You can hear the noise bounce around, but nobody on the street can see him.”

No permits were required because it was on private property, officials said.

The decision to ax the marquee performance came days after a free concert by rapper Drake at the South Street Seaport was canceled last Tuesday after the gathered crowd of more than 10,000 grew unruly.