Sebastian Vettel denied Lewis Hamilton pole position for the Malaysian Grand Prix in an extremely close battle at Sepang.