Anna van der Breggen moved into the Giro Rosa lead with one day to go as Elisa Longo Borghini won stage eight.
Van der Breggen and Longo Borghini went clear on the steep final climb to drop Niewiadoma and the rest of the field.
Italy’s Longo Borghini then claimed the two-up sprint in San Marco la Catola.
New Zealand’s Mikayla Harvey took third, 31 seconds back, while Niewiadoma finished sixth, one minute 19 seconds down.
Olympic champion Van der Breggen, who started the day 15 seconds down on Niewiadoma, now leads the Polish rider by one minute 10 seconds in the pink jersey.
The Dutch Boels-Dolmans rider, who is set to retire after next year’s rescheduled Tokyo Olympics, looks on course to win her third Giro Rosa title, having also won in 2015 and 2017.
“It’s a bit strange,” said Van der Breggen. “It’s not how everybody thought it would be, and not how you would like to take pink, but on the other hand, you could really feel that the fighting spirit was really back for pink again and everybody was focused.”
Longo Borghini, who took the race lead on stage one after Trek-Segafredo won the team time trial, is now up to third overall, two minutes 23 seconds back.
Saturday’s final stage is a mountainous 110km route that sees the riders tackle four laps around Motta Montecorvino, culminating in an uphill finish.