Lavielle prevails in close race over Thomas