China detonated a nuclear device underground Tuesday, defying an international moratorium on nuclear testing and a personal plea from President Clinton. The government said it needs to develop nuclear weapons for its self-defense.

In response, Clinton directed the U.S. Energy Department to prepare for possible resumption of underground nuclear testing."The United States deeply regrets this action. We urge China to refrain from further nuclear tests and to join the other nuclear powers in a global moratorium," Clinton said in a statement issued by the White House.

As foreign governments denounced the test, picked up by seismic monitors, China said it will stop nuclear tests only after a comprehensive test-ban treaty is in place.

In a statement acknowledging the detonation, Beijing repeated its vow not to be the first to use nuclear weapons.

"It is entirely for the purpose of self-defense that China develops and possesses a small number of nuclear weapons," said the statement, read over China Central Broadcasting radio station.

In a clear reference to the United States, the statement said it was up to countries with the largest nuclear arsenals to "bear the special responsibility by taking the lead to cut down their own nuclear development."

It pledged China will work with other countries to achieve a test-ban treaty "no later than 1996," but made no promise regarding testing before an agreement is reached.

Seismic monitors picked up the blast early Tuesday in far northwestern China, said the London-based Verification Technology Information Center and the Swedish defense research agency FAO.

"So far 71 seismic stations have detected the explosion. More will pick it up as time goes by once they realize it is on their seismometers," said Vipin Gupta of the Verification Technology Information Center, which accurately forecast China's last nuclear tests, in 1992.

The test could undermine the moratorium on nuclear testing being observed by the world's four other acknowledged nuclear powers, the United States, Russia, France and Britain.