Context. Ultrahigh-energy cosmic rays (UHECRs) are charged particles with energies surpassing 1018 eV. Their sources remain elusive because they are obscured by deflections caused by the Galactic magnetic field (GMF). This challenge is further complicated by our limited understanding of the 3D structure of the GMF because current GMF observations primarily consist of quantities that are integrated along the line of sight (LOS). Nevertheless, data from upcoming stellar polarization surveys along with Gaia stellar parallax data are expected to yield local GMF measurements. Aims. This study is the second entry in our exploration of a Bayesian inference approach to the local GMF that uses synthetic local GMF observations that emulate forthcoming local GMF measurements, and attempts to use them to reconstruct its 3D structure. The ultimate aim is to trace back observed UHECRs and thereby update our knowledge about their possible origin. Methods. In this proof-of-concept work, we assumed as ground truth a magnetic field produced by a dynamo simulation of the Galactic ISM. We employed methods of Bayesian statistical inference in order to sample the posterior distribution of the GMF within part of the Galaxy. By assuming a known rigidity and arrival direction of an UHECR, we traced its trajectory back through various GMF configurations drawn from the posterior distribution. Our objective was to rigorously evaluate the performance of our algorithm in scenarios that closely mirror the setting of expected future applications. In pursuit of this, we conditioned the posterior to synthetically integrated LOS measurements of the GMF, in addition to synthetic local plane of sky-component measurements. Results. Our results demonstrate that for all locations of the observed arrival direction on the plane of sky, our algorithm is able to substantially update our knowledge on the original arrival direction of UHECRs with a rigidity of E/Z = 5 × 1019 eV, even without any LOS information. When the integrated data are included in the inference, the regions of the celestial sphere in which the maximum error occurs are greatly reduced. The maximum error is diminished by a factor of about 3 even in these regions in the specific setting we studied. Additionally, we are able to identify the regions in which the largest error is expected to occur.