Understanding specialization patterns of countries in food production can provide relevant insights for the evaluation and design of policies seeking to achieve food security and sustainability, which are key to reach several Sustainable Development Goals (SDGs). This paper builds bipartite networks of food products and food-producing countries, using FAO data from 1993 to 2013, to characterize the global food production system. We use methods from complex systems analysis to rank products according to their need for capabilities and countries according to their competitiveness, which derives from the quality and diversification of their food production baskets. We observe two well-defined communities of food-producing countries, one that groups countries with relatively developed agricultural systems, and the other grouping countries with less developed production systems. The stability of these two communities reveals persistent differences between countries specialization patterns. We econometrically analyze whether and how specialization patterns affect food supply, food security (SDGs: Targets 2.1 and 2.2), and sustainability of food systems (SDGs: Target 2.4). We show that concentrating agricultural production negatively impacts food supply, food security, and food systems sustainability. The competitiveness of countries and the coherence of their diversification patterns increase per capita food supply and food security but might harm sustainability. This evidence reflects the trade-off between achieving food security while simultaneously improving sustainability, which needs to be considered when developing or implementing policies seeking to reach SDGs.