Talansky battled on the climb to the top of Mt Baldy with race leader Rafal Majka (BORA-hansgrohe), George Bennett (LottoNL-Jumbo) and Ian Boswell (Sky) after the peloton caught and passed Rally Cycling's solo breakaway Rob Britton five kilometres from the finish.
He finished ahead of Majka with Bennett third and Boswell fourth at the end of the 125.5km stage from Ontario.
Majka continues to lead the race after fending off Bennett's attempt to grab the bonus seconds on offer at the finish.
“I didn’t win but I think that second was still a good result," Majka said. " I'd like to thank all my teammates for the excellent work they did today.
"Tomorrow I’ll try to keep the jersey, but it’ll be difficult with Talansky. I wanted to gain some time today but it wasn’t easy. I didn’t know the finish. There were a lot of corners and with 100 metres to go I tried to sprint, but Talansky passed me on the left-hand side. Congratulations to him on his win.
"I’m still happy with this second place but tomorrow we need to try to keep the jersey. When we look at the race so far, I’ve been strong and I don’t feel too bad. For the time trial tomorrow it’s 24km and I’ll try to keep the jersey.”
Bennett sits just six seconds behind Majka, Boswell is at 19 seconds and Talansky 44, with a decisive 24km time trial to come at Big Bear Lake.
Talansky's victory was the first on the World Tour for Cannondale-Drapac in two years.