The invention discloses a five-degree-of-freedom stacking mechanical arm capable of automatically sorting and discharging a material. The five-degree-of-freedom stacking mechanical arm capable of automatically sorting and discharging the material aims to achieve the advantages that different types of cartons can be automatically sorted, stored and packed, the labor investment is reduced, and the production efficiency is increased. According to the technology scheme, the mechanical arm comprises a plurality of placement tables and a conveying mechanism, wherein the plurality of placement tablesare used for storing the cartons with different types, and the conveying mechanism is positioned among the placement tables and used for conveying the cartons; and an automatic material discharging assembly is arranged on one side of the conveying mechanism, the automatic material discharging assembly comprises a machine frame, trays, a sorting mechanism and a carrying manipulator, each tray is provided with a code scanning piece, the part, in the machine frame, of the conveying mechanism is provided with a corresponding code reading piece. The cartons with different models and different sizes can be automatically transported and carried to the designated trays for packaging, the cartons can be automatically sorted and stored, so that the investment of manpower is greatly reduced, the production efficiency is improved, and the influence on the operation safety of an operator is not prone to be caused.