Rafael Nadal overcame a tricky test against Ernests Gulbis to advance to the semi-finals of the ATP Qatar ExxonMobil Open.