The blaze began in the morning in the building at Kadena Air Base and was extinguished several hours later, the U.S. Air Force said.
Japanese television showed thick gray plumes of smoke billowing from the building, called the 18th wing Hazardous Materials Pharmacy. The area was closed off and personnel in the area were evacuated as firefighters battled the fire, the Air Force said in a statement.
About 45 people in the area were exposed to smoke and chlorine gas from the fire, but were treated and most have returned to duty, the statement said.
The cause of the fire is still unknown, it said. It said bio-environmental experts and emergency staff remained at the site to monitor the aftermath and ensure there was no risk to the community.
Kadena is the largest U.S. air base in the Far East.
More than half of about 50,000 U.S. troops in Japan are stationed on Okinawa under a bilateral security pact. Many residents of Okinawa have complained about environmental hazards, noise and crime related to the U.S. military presence.
In April, more than 140 tons of firefighting foam believed to contain cancer-causing substances leaked from Marine Air Station Futenma, which is at the center of a relocation dispute. Japan's Defense Ministry said last month that water samples showed no major problems.