Fernando Gaviria earned his second stage win of the race ©Quick-Step Team/Twitter

Fernando Gaviria sprinted to victory in a chaotic finale to the fifth stage of the Tour of California, as Kendall Ryan triumphed on the opening day of the women’s race.

The sprinters were expected to contest the stage victory in the men’s race on a flat 176 kilometre route from Stockton to Elk Grove.

Britain’s Mark Cavendish and Germany’s Marcel Kittel looked out of contention in the run in to the finish, after puncturing inside the final 10km of racing.

The former was able to make his way back through the field, but narrowly avoided a crash with took down several riders.

The incident at 5km to go created chaos in the peloton, causing confusion about the lead out trains.

Gaviria emerged from the pack to clinch his second stage win of the race, crossing the line in 4hours 4min 34sec.

Australia’s Caleb Ewan and Slovakia’s world champion Peter Sagan would round off the top three, ending on the same time as the winner.

Tejay Van Garderen retained his 23 seconds cushion over Colombia’s Egan Bernal at the top of the standings, with the American now two days away from clinching the overall title.

The three-day women’s race began with a 124km stage, which also finished in Elk Grove.

Despite a couple of attacks on the route, the flat course made a bunch sprint almost and inevitability.

Ryan came through to secure her first victory on the International Cycling Union Women’s WorldTour, with the American crossing the line first in 3:07:08.

She was followed across the line by her compatriot Emma White, with Australia’s Annette Edmondson ending in third place.

Racing will continue tomorrow with a 108km stage, which starts and finishes in South Lake Tahoe.