The structure of the new magnesium nitridoboride MgNB9 consists of two layers alternating along the c axis. The NB6 layer, with B12 icosahedra, has the C2B13 structure type. Within this layer, boron icosahedra are bonded to N atoms, each coordinating to three boron polyhedra. Another MgB3 layer, with B6 octahedra, does not belong to any known structure type. The boron icosahedra and octahedra are connected to each other, thus forming a three-dimensional boron framework.