Introduction: Autonomic nervous system (ANS) plays an important role in the exchange of metabolic information between organs and regulation on peripheral metabolism with obvious circadian rhythm in a healthy state. Sleep, a vital brain phenomenon, significantly affects both ANS and metabolic function. Objectives: This study investigated the relationships among sleep, ANS and metabolic function in type 2 diabetes mellitus (T2DM), to support the evaluation of ANS function through heart rate variability (HRV) metrics, and the determination of the correlated underlying autonomic pathways, and help optimize the early prevention, post-diagnosis and management of T2DM and its complications. Materials and methods: A total of 64 volunteered inpatients with T2DM took part in this study. 24-h electrocardiogram (ECG), clinical indicators of metabolic function, sleep quality and sleep staging results of T2DM patients were monitored. Results: The associations between sleep quality, 24-h/awake/sleep/sleep staging HRV and clinical indicators of metabolic function were analyzed. Significant correlations were found between sleep quality and metabolic function (|r| = 0.386 ± 0.062, p < 0.05); HRV derived ANS function showed strengthened correlations with metabolic function during sleep period (|r| = 0.474 ± 0.100, p < 0.05); HRV metrics during sleep stages coupled more tightly with clinical indicators of metabolic function [in unstable sleep: |r| = 0.453 ± 0.095, p < 0.05; in stable sleep: |r| = 0.463 ± 0.100, p < 0.05; in rapid eye movement (REM) sleep: |r| = 0.453 ± 0.082, p < 0.05], and showed significant associations with glycemic control in non-linear analysis [fasting blood glucose within 24h of admission (admission FBG), |r| = 0.420 ± 0.064, p < 0.05; glycated hemoglobin (HbA1c), |r| = 0.417 ± 0.016, p < 0.05]. Conclusions: HRV metrics during sleep period play more distinct role than during awake period in investigating ANS dysfunction and metabolism in T2DM patients, and sleep rhythm based HRV analysis should perform better in ANS and metabolic function assessment, especially for glycemic control in non-linear analysis among T2DM patients.