Vertex algebras were first introduced as a tool used in the description of the algebraic structure of certain quantum field theories. It became increasingly important that vertex algebras are useful not only in the representation theory of infinite-dimensional Lie algebras, where they are by now ubiquitous, but also in other fields, such as algebraic geometry, theory of finite groups, modular functions, and topology. This book is an introduction to the theory of vertex algebras with a particular emphasis on the relationship between vertex algebras and the geometry of moduli spaces of algebraic curves. The authors make the first steps toward reformulating the theory of vertex algebras in a way that is suitable for algebraic-geometric applications. The notion of a vertex algebra is introduced in the book in a co-ordinate independent way, allowing the authors to give global geometric meaning to vertex operators on arbitrary smooth algebraic curves, possibly equipped with some additional data. To each vertex algebra and a smooth curve, they attach an invariant called the space of conformal blocks. When the complex structure of the curve and other geometric data are varied, these spaces combine into a sheaf on the relevant moduli space. From this perspective, vertex algebras appear as the algebraic objects that encode the geometric structure of various moduli spaces associated with algebraic curves. Numerous examples and applications of vertex algebras are included, such as the Wakimoto realization of affine Kac-Moody algebras, integral solutions of the Knizhnik-Zamolodchikov equations, classical and quantum Drinfeld-Sokolov reductions, and the $W$-algebras. The authors also establish a connection between vertex algebras and chiral algebras, introduced by A. Beilinson and V. Drinfeld.