WASHINGTON — Speaker John A. Boehner, an Ohio barkeeper’s son who rode a conservative wave to one of the highest positions in government, said Friday he would relinquish his gavel and resign from Congress, undone by the very Republicans who swept him into power.

Mr. Boehner, 65, made the announcement in an emotional meeting with his fellow Republicans on Friday morning as lawmakers struggled to avert a government shutdown next week, a possibility made less likely by his decision.

Mr. Boehner told almost no one of his decision before making it Friday morning. “So before I went to sleep last night, I told my wife, I said, ‘You know, I might just make an announcement tomorrow,’ ” Mr. Boehner said at a news conference in the Capitol. “This morning I woke up, said my prayers, as I always do, and thought, ‘This is the day I am going to do this.’ ”

His downfall again highlighted the sinewy power of a Republican Party faction whose anthem is often to oppose government action. It also made vivid the increasingly precarious nature of a job in which the will and proclivities of a politically divisive body must be managed. No House speaker since Thomas P. O’Neill Jr., who held the gavel from 1977 to 1986, has left the job willingly.