The optimal power flow (OPF) problem is nonconvex and generally hard to solve. We show that the dual of an equivalent form of OPF is a semidefinite program (SDP) and hence convex. We prove a sufficient condition under which the duality gap is zero, in which case an optimal solution of the OPF problem can be efficiently computed from a solution of the dual problem. Interestingly, the standard IEEE benchmark systems with 14, 30, 57, 118 and 300 buses all satisfy this condition and are therefore efficiently solvable.