The close approach to the Earth of Comet C/1996 B2 (Hyakutake) in March 1996 allowed searches for minor volatile species outgassed from the nucleus. We report the detection of deuterated water (HDO) through its 101-000rotational transition at 464.925 GHz using the Caltech Submillimeter Observatory. We also present negative results of a sensitive search for theJ(5-4) line of deuterated hydrogen cyanide (DCN) at 362.046 GHz.Simultaneous observations of two rotational lines of methanol together with HDO in the same spectrum allow us to determine the average gas temperature within the telescope beam to be 69 ± 10 K. We are thus able to constrain the excitation conditions in the inner coma and determine reliably the HDO production rate as (1.20 ± 0.28) × 1026s-1on March 23-24, 1996. Available IR, UV, and radio measurements led to a water production rate of (2.1 ± 0.5) × 1029s-1at the time of our HDO observations. The resulting D/H ratio in cometary water is thus (29 ± 10) × 10-5, in good agreement with the values of (30.8+3.8-5.3) × 10-5(H. Balsigeret al., 1995,J. Geophys. Res.100, 5827-5834). and (31.6 ± 3.4) × 10-5(P. Eberhardet al., 1995,Astron. Astrophys.302, 301-316) determined in Comet P/Halley fromin situion mass spectra. The inferred 3σ upper limit for the D/H ratio in HCN is 1%. Deuterium abundance is a key parameter for studying the origin and the early evolution of the Solar System and of its individual bodies. Our HDO measurement confirms that, in cometary water, deuterium is enriched by a factor of at least 10 relative to the protosolar ratio, namely the D/H ratio in H2in the primitive Solar Nebula which formed from the collapse of the protosolar cloud. This indicates that cometary water has preserved a major part of the high D/H ratio acquired in this protosolar cloud through ion-molecule isotopic exchanges or grain-surface reactions and was not re-equilibrated with H2in the Solar Nebula. However, there are strong presumptions that interstellar grains were partly mixed in the early nebula prior to cometary formation with water reprocessed in the warm inner part of the nebula and transported by turbulent diffusion. Scenarios of formation of comets consistent with these results are discussed.