Edvald Boasson Hagen won Stage 19 of the Tour de France as Chris Froome crossed safely in the pack to retain the yellow jersey with two stages to go.

Norwegian Boasson Hagen has been on the wrong side of two photo finishes so far in this Tour but made certain of victory in Salon-de-Provence as he attacked out of the breakaway with three kilometres to go and soloed to the line.

Nikias Arndt did his best to keep up but the Team Sunweb man came home in second place, five seconds behind.

That all happened a good 12 and a half minutes before the peloton crossed the line, with the contenders taking it relatively easy after two hard days in the Alps.

Froome leads by 23 seconds from Frenchman Romain Bardet and 29 seconds from Colombian Rigoberto Uran going into Saturday's penultimate stage, a 22.5km time trial starting and finishing in Marseille's Velodrome stadium.

Chris Froome will take a 23 second lead into tomorrow's time trial in Marseille LIONEL BONAVENTURE/AFP/Getty Images

Team Dimension Data's Boasson Hagen was denied by just six millimetres -- or 0.0003 seconds -- when Marcel Kittel won stage seven to Nuits-Saint-Georges in the first week of the Tour. He was then narrowly beaten again by the German on stage 12 to Pau, a victory that would have been all the sweeter for Boasson Hagen's South African-based team as it would have come on Nelson Mandela Day.

A day after the final mountain test, the organisers threw the longest stage of the entire Tour at the riders as they rode 222.5km from Embrun.

Although this stage was listed as flat, Team Sky were eager to avoid it coming to a sprint finish given the technical nature of the final three kilometres -- with three sharp bends perhaps inviting a crash if the race was on.

As such, they allowed a 20-man break -- also including another ex-Team Sky man in the shape of Ben Swift -- to go more than 10 minutes up the road.

It began to fracture inside the final 20km, with Boasson Hagen part of a nine-man group that left Swift and the others behind.

When the 30-year-old kicked again with less than three kilometres to go, Arndt was the only one to respond but the German could not keep up.

General Classification

1. Chris Froome 83h 26' 55''

2. Romain Bardet + 00' 23''

3. Rigoberto Uran + 00' 29''

Sprinters Jersey

1. Michael Matthews 364

2. Andre Greipel 204

3. Edvald Boasson Hagen 200

King of the Mountains

1. Warren Barguil 169

2. Primoz Roglic 80

3. Thomas de Gendt 64

Young Riders

1. Simon Yates 83h 31' 41''

2. Louis Meintjes + 02' 06''

3. Emanuel Buchmann + 26' 15''