Background: Our previous studies had shown pirfenidone (PFD) not only improved tubulointerstitial fibrosis (TIF) but also inhibited the expression of microRNA-21 (miR-21) in the renal tissue of unilateral urethral obstruction (UUO) rats. This study aims to investigate whether PFD can attenuate TIF through inhibiting miR-21 in UUO rats. Methods: Sprague Dawley rats were divided randomly into sham-operated group, UUO group, and PFD and olmesartan (Olm) treatment groups. Samples were collected on day 14. Expression of miR-21, TGF-β1, Smad3, and Smad7 mRNA in the renal tissue was detected using real-time quantitative PCR. Immunohistochemistry was performed to assess the protein expressions of collagen III, E-cadherin, and α-SMA. Automated capillary Western blotting was used to detect the quantitative expression of TGF-β1, Smad3, p-Smad3, Smad7, collagen III, E-cadherin, and α-SMA in renal tissues. The expression of miR-21 and Smad7 mRNA and the protein levels of collagen III and α-SMA were examined in the miR-21-overexpressing cell line, NRK-52E. Results: Compared with the UUO group, both PFD and Olm inhibited renal tubular dilation, diffused epithelial cell degeneration and necrosis, and reduced renal interstitial edema, inflammatory cell infiltration, and collagen fiber deposition, while no significant difference between PFD group and Olm group. Informatics-based approaches identified Smad7 as a likely candidate for regulation by miR-21. Compared with the sham group, miR-21 expression was upregulated in the UUO group resulting in the downregulation of Smad7 expression due to degradation. The overexpression of miR-21 in the in vitro model downregulated Smad7 and promoted EMT and ECM accumulation. Protein levels of TGF-β1, Smad3, p-Smad3, collagen III, and α-SMA were upregulated, while E-cadherin protein was downregulated in the UUO group than in the sham group. PFD rather than Olm decreased the expression of miR-21 and increased the expression level of Smad7 mRNA and then inhibited the TGF-β1/Smad3 signaling pathway. Olm only downregulated the TGF-β1/Smad3 signaling pathway. Conclusions: PFD improves TIF by downregulating the expression of miR-21, then elevating Smad7, and finally inhibiting the activation of the TGF-β1/Smad3 signaling pathway in UUO rats.