A long-standing open question asks for the minimum number of vectors needed to form an unextendible product basis in a given bipartite or multipartite Hilbert space. A partial solution was found by Alon and Lovasz in 2001, but since then only a few other cases have been solved. We solve all remaining bipartite cases, as well as a large family of multipartite cases.