WASHINGTON — Representative Eric Cantor, the Virginia Republican whose last day as House majority leader was Thursday, said on Friday that he would resign his seat effective Aug. 18 in hopes that his successor will be able to participate in the lame-duck session after the November elections.

Mr. Cantor, 51, made the announcement in an op-ed article published on The Richmond Times-Dispatch website.

He lost the Republican primary in his Northern Virginia district in June to David Brat, a little-known and more conservative candidate with Tea Party backing. The results shocked Washington and led to a shake-up in the House leadership after Mr. Cantor said he would resign as the No. 2 House Republican. He said he hoped to prevent an intraparty fight from festering in the months before the midterm elections.

But the news that he would give up his seat early was a surprise.

“It is vitally important that the constituents have a clear and strong voice during the consequential lame-duck session of Congress,” Mr. Cantor wrote in The Times-Dispatch. “The issues that will be considered during the lame-duck session this year will be crucial to the future of our country. These debates will continue into the new Congress, and the people of this district deserve to have their new voice representing them and engaging on their behalf.”