The tyrosine phosphorylation barcode encoded in C-terminus of HER2 and its ubiquitination regulate diverse HER2 functions. PTPN18 was reported as a HER2 phosphatase; however, the exact mechanism by which it defines HER2 signaling is not fully understood. Here, we demonstrate that PTPN18 regulates HER2-mediated cellular functions through defining both its phosphorylation and ubiquitination barcodes. Enzymologic characterization and three crystal structures of PTPN18 in complex with HER2 phospho-peptides revealed the molecular basis for the recognition between PTPN18 and specific HER2 phosphorylation sites, which assumes two distinct conformations. Unique structural properties of PTPN18 contribute to the regulation of sub-cellular phosphorylation networks downstream of HER2, which are required for inhibition of HER2-mediated cell growth and migration. Whereas the catalytic domain of PTPN18 blocks lysosomal routing and delays the degradation of HER2 by dephosphorylation of HER2 on pY(1112), the PEST domain of PTPN18 promotes K48-linked HER2 ubiquitination and its rapid destruction via the proteasome pathway and an HER2 negative feedback loop. In agreement with the negative regulatory role of PTPN18 in HER2 signaling, the HER2/PTPN18 ratio was correlated with breast cancer stage. Taken together, our study presents a structural basis for selective HER2 dephosphorylation, a previously uncharacterized mechanism for HER2 degradation and a novel function for the PTPN18 PEST domain. The new regulatory role of the PEST domain in the ubiquitination pathway will broaden our understanding of the functions of other important PEST domain-containing phosphatases, such as LYP and PTPN12.