Under Peruvian law, an election victory for Keiko Fujimori would see graft charges suspended until after her term, but defeat would see her go to trial.
The statistical tie had Fujimori leading with 50.3 percent of the vote, while Castillo had 49.7 percent, within the margin of error of plus or minus 3 percentage points, according to the poll.
With nearly 90 percent of ballots counted, leftist Pedro Castillo was in the lead with 18.83 percent - much higher than predicted by opinion polls which had not even placed him in the top five.
Fujimori left the woman's prison in the capital Lima on bail wearing a face mask and white gloves. She had earlier announced on Twitter that she would head straight from the facility to take a coronavirus test.
President Martin Vizcarra has succeeded in channeling public outrage as he pushes Sunday's vote as an essential decree to "end the plague of corruption."
Fujimori's lawyer said that the conservative politician was taken into custody after showing up at the chief prosecutor's office. She was to provide testimony in an ongoing probe into dubious financial contributions to her 2011 presidential campaign.
The pardon comes just days after a faction of Fujimori's supporters in the opposition-controlled Congress saved current President Kuczynski from a motion that would have forced him from office in the wake of a graft scandal.
Peru's President Pedro Pablo Kuczynski is facing impeachment counts over allegedly receiving bribes from a Brazilian company through his private business. Here's a need-to-know about 'Latin America's biggest corruption scandal'.
Opposition-controlled Congress dismissed the cabinet of centre-right President Pedro Pablo Kuczynski, pitching the country into its worst political crisis in years.
With more than 98.7 percent of ballots counted, Pedro Pablo Kuczynski has gained over 50 percent of the votes while his opponent Keiko Fujimori has 49.83 percent.
Pedro Pablo Kuczynski leads in the Peruvian presidential elections against his rival Keiko Fujimori by less than 1 percent.
Peru markets rise after two pro-business candidates Keiko Fujimori, Pablo Kuczynski move on to second round of presidential election
Subscribe to our Youtube channel for all latest in-depth, on the ground reporting from around the world.
Copyright © 2021 TRT World.