BEIJING — The Forbidden City has not really been forbidden to the public for decades, except in one respect. It was closed at night to all but the privileged few — until this week.

For the first time since 1925, when the former home of the emperors of the Ming and Qing dynasties became a museum, the Forbidden City has opened its doors to the public at night for two days this week, allowing visitors the chance to see its palaces and temples bathed in ethereal lights.

The idea proved to be a hit.

A webpage that the museum created for people to register for free tickets crashed because of traffic. The museum ultimately gave away 500 tickets for people to join 2,500 invited guests on Tuesday, and another 3,000 tickets for Wednesday night.

Soon, tickets were being scalped online. Two sellers reached by phone offered tickets for 4,000 yuan each, or about $595.

Those who managed to get into the event saw an array of light displays and projections, as well as a performance by the Peking Opera staged at the Belvedere of Pleasant Sounds, the Forbidden City’s largest theater. The music could be heard throughout the complex, which was far less crowded than it normally was during the day.

Illuminated red lanterns were hung along walkways and a wall that surrounds the complex, which was also recently opened to visitors. The museum said in a statement that the Forbidden City had not opened at night before because of the cost and complexity of providing security for relics in nearly 1,000 buildings spread over 180 acres.

The museum organized the openings to coincide with the annual Lantern Festival, marking the 15th day of the first month of the lunar year. It was part of an effort to revitalize the image of a museum complex that has been notoriously conservative.

“The more the Forbidden City does, the more influential it will be,” said the museum’s director, Shan Jixiang.

Yang Jie, who visited the museum with her husband on Tuesday night, described the illuminated complex as “electrifying.”

“It makes it possible to see a different side of the Forbidden City,” she said.