We construct the derived version of the Hilbert scheme parametrizing subschemes in a given projective scheme
X
X
with given Hilbert polynomial
h
h
. This is a dg-manifold (smooth dg-scheme)
R
H
i
l
b
h
(
X
)
RHilb_h(X)
which carries a natural family of commutative (up to homotopy) dg-algebras, which over the usual Hilbert scheme is given by truncations of the homogeneous coordinate rings of subschemes in
X
X
. In particular,
R
H
i
l
b
h
(
X
)
RHilb_h(X)
differs from
R
Q
u
o
t
n
(
O
X
)
RQuot_n({\mathcal O_X})
, the derived Quot scheme constructed in our previous paper, which carries only a family of
A
∞
A_\infty
-modules over the coordinate algebra of
X
X
. As an application, we construct the derived version of the moduli stack of stable maps of algebraic curves to a given projective variety
Y
Y
, thus realizing the original suggestion of M. Kontsevich.