The legislation proposed that the term of current President Dina Boluarte end on April 30, 2024, with her successor serving the rest of the 2021-2026 presidential term started by Castillo, reports Xinhua news agency.
The initiative on Wednesday received 54 in favour, 68 against and two abstentions.
Boluarte had previously urged lawmakers to adopt the bill and promised to move forward with constitutional reform to advance the election if the legislation fails.
Within the deeply fragmented Congress, some lawmakers wish to complete their original term, while others want to go further and hold a referendum for a new constitution.
Political unrest in Peru had sparked on December 7, 2022, when Boluarte took office following the ouster of her predecessor.
The Peruvian Congress impeached Castillo just hours after his failed attempt to dissolve the legislature.
Castillo was then detained by security forces.
Among the protesters’ demands are early elections, Castillo’s release from custody and Boluarte’s resignation.
At least 56 people have died in the subsequent unrest.
The government has been accused of using excessive force in its efforts to quell the protests, and Peru’s ombudsman said that, of the total victims, 46 were involved in clashes with the security forces.
The Governors of Puno, Cusco and Apurimac regions have also called for the President’s resignation.