Ferrari's Carlos Sainz secured his first win in Formula One in what was an exhilarating British Grand Prix.