The present study evaluated the effect of ultrasonic agitation on the porosity distribution of BioRoot RCS/single gutta-percha cone (BR/SC) and MTA Flow (MF) root canals fillings used as apical plugs in moderately curved and apically perforated roots. Eighty mesial root canals of mandibular first molars were enlarged up to ProTaper NEXT X5 rotary instrument 2 mm beyond the apical foramen, simulating apical perforations. Specimens were randomly divided into four experimental groups (20 canals per group) according to the material and technique used for root canal obturation: BR/SC, BR/SC with ultrasonic agitation (BR/SC-UA), MF and MF with ultrasonic agitation (MF-UA). The ultrasonic tip was passively inserted into the root canal after the injection of flowable cement and activated for 10 s. The specimens were scanned before and after obturation with a high-resolution micro-computed tomography scanner, and the porosity of the apical plugs was assessed. The differences between groups were analyzed using the Kruskal-Wallis and Mann-Whitney tests, with the significance level set at 5%. None of the obturation materials and techniques used in this study was able to provide a pore-free root canal filling in the apical 5 mm. Considerably higher percentages of open and closed pores were observed in the MF and MF-UA groups, with the highest porosity being in the MF-UA group (p < 0.05). No significant differences were observed between the BR/SC and BR/SC-UA groups, where the quantity of open and closed pores remained similar (p > 0.05).