RICHMOND, Virginia (AP) — After a surprise primary election loss, Republican Congressman Eric Cantor will resign his seat in the House of Representatives months earlier than expected.

The congressman will step down Aug. 18 and ask Virginia Gov. Terry McAuliffe to call a special election to enable his successor to take office immediately, Cantor spokesman Doug Heye said Friday.

Hours after stepping down as House majority leader Thursday, Cantor told the Richmond Times-Dispatch (http://bit.ly/1puQVLX) he would step down instead of serving his full term, which would have ended in January.

Cantor told the newspaper a special election would give the winner seniority rather than waiting until January to take office with the new Congress.

Cantor lost to Dave Brat, an underfunded opponent loosely linked to the conservative tea party movement, in the June Republican primary.

Cantor, 51, is a seven-term House veteran who before his defeat had been seen as a potential rival — and likely successor — to House Speaker John Boehner. Though he had a conservative voting record, he was distrusted by some tea party supporters who suspected he might be too eager to reach compromise on immigration legislation.