In the United States, the effectiveness of anal cancer screening programs has been limited by a lack of trained professionals proficient in high-resolution anoscopy (HRA) and a high patient lost-to-follow-up rate between diagnosis and treatment. Simplifying anal intraepithelial neoplasia grade 2 or more severe (AIN 2+) detection could radically improve the access and efficiency of anal cancer prevention. Novel optical imaging providing point-of-care diagnoses could substantially improve existing HRA and histology-based diagnosis. This work aims to demonstrate the potential of high-resolution microendoscopy (HRME) coupled with a novel machine learning algorithm for the automated, in vivo diagnosis of anal precancer. The HRME, a fiber-optic fluorescence microscope, was used to capture real-time images of anal squamous epithelial nuclei. Nuclear staining is achieved using 0.01% wt/vol proflavine, a topical contrast agent. HRME images were analyzed by a multitask deep learning network (MTN) that computed the probability of AIN 2+ for each HRME image. The study accrued data from 77 people living with HIV. The MTN achieved an area under the receiver operating curve of 0.84 for detection of AIN 2+. At the AIN 2+ probability cutoff of 0.212, the MTN achieved comparable performance to expert HRA impression with a sensitivity of 0.92 ( P = 0.68) and specificity of 0.60 ( P = 0.48) when using histopathology as the gold standard. When used in combination with HRA, this system could facilitate more selective biopsies and promote same-day AIN2+ treatment options by enabling real-time diagnosis.