Lewis Hamilton wins Bahrain Grand Prix thriller