WASHINGTON, DC - OCTOBER 26: Committee chairman Rep. Bob Goodlatte (R-VA) questions witnesses during a House Judiciary Committee hearing concerning the oversight of the U.S. refugee admissions program, on Capitol Hill, October 26, 2017 (Drew Angerer/Getty Images)

Two days after Republicans suffered sweeping defeats up and down the ballot in Virginia, Rep. Bob Goodlatte (R), chairman of the House Judiciary Committee, announced Thursday he will not seek reelection.

The 13-term congressman from Roanoke will end his congressional career “after much contemplation and prayer,” he said in a statement.

“With my time as chairman of the Judiciary Committee ending in December 2018,” he said, “this is a natural stepping-off point and an opportunity to begin a new chapter of my career and spend more time with my family, particularly my granddaughters.”

House rules bar Goodlatte from serving another term as chairman of the influential committee. He was previously chairman of the House Agriculture Committee.

Goodlatte joins more than a dozen mostly Republican members of the House and Senate who plan to retire at a time when the GOP-controlled Congress has struggled to pass major legislation, such as a repeal of the Affordable Care Act.

On a call with reporters, Goodlatte said the political climate “didn’t play a role” in his decision.

If he ran again, he could have faced a tough fight for the GOP nomination. As an elected official for more than a quarter-century, he has been a target of activists with disdain for entrenched politicians.

“There are a lot of legitimately angry people out here who are frustrated with the inaction of Washington generally and are ­focusing their anger on incumbents who they perceive as being part of the problem,” said state Del. C. Todd Gilbert (R-Shenandoah), a Goodlatte ally whose district overlaps his. “If you have been there as long as Bob has been, you rightly wear part of that criticism.”

Within hours of his announcement, two Republicans — a conservative state delegate who once worked for Goodlatte and a GOP national committeewoman — announced they would compete for the nomination. Both are setting themselves as Washington outsiders.

Goodlatte, 65, the most senior Republican in the state’s congressional delegation, is known as a student of policy who closely follows state and local GOP politics.

Over the next 14 months, he said, he hopes to bolster enforcement of immigration laws and overhaul the legal immigration system as well as simplify the tax code, enact criminal justice reform and repeal the Affordable Care Act.

The latest stories and details on the 2017 Virginia general election and race for governor.

He would do this while “advancing protections of the freedoms and liberties enshrined in our Constitution,” he said.

The congressman made news in January when his plan to gut the Office of Congressional Ethics prompted public outcry and critical tweets from the incoming President Trump, whose policies Goodlatte has publicly supported.

Last year, Trump easily carried his district, which stretches from the Shenandoah Valley to the Roanoke Valley and east to Lynchburg, the home of Liberty University. Ed Gillespie, the Republican candidate for governor, won 61 percent of the vote in the district this week, despite losing the state by 9 points.

Despite a solid conservative voting record, Goodlatte has drawn the ire of Republican activists in his district, including those who run the influential party apparatus.

Cynthia Dunbar, a GOP national committeewoman, and Del. Benjamin L. Cline (R-Rockbridge), Goodlatte’s former chief of staff, said Thursday they are running for the GOP nomination.

Dunbar said she has “witnessed firsthand the disarray and dysfunction inside Congress which is crippling our Republic” when it comes to the national debt, taxes and immigration policy.

“As constitutional conservatives, we can no longer allow career politicians to focus on the next election as opposed to current problems facing our nation,” she said.

Cline announced his campaign with similar rhetoric, saying he was “fed up with the dysfunction gripping Washington.”

“For far too long, Washington insiders have ignored families outside their insular ‘Beltway.’ Again and again they have proved they are out of touch and tone deaf to our struggles,” he said, while thanking his former boss for his service.

Democrats Sergio Coppola and Peter Volosin are running, and Andy Parker, the father of a broadcast journalist who was killed on live television two years ago, said he is considering joining the Democratic field.

Eric Cantor, the former House majority leader who was beaten in 2014 in the Republican primary by Rep. Dave Brat, said Goodlatte dispatched with past primary challengers with what looked like relative ease.

“But it wasn’t something that just came by chance,” he said. “He always was deliberate about making sure he was there for the people of Roanoke Valley and the 6th District.”

Virginia Democrats Rep. Robert C. “Bobby” Scott, who entered Congress the same year as Goodlatte, and Sens. Mark R. Warner and Tim Kaine noted they didn’t often agree with his policies but thanked Goodlatte and his wife, Maryellen.

The son of a manager of Friendly’s restaurants in Massachusetts, Goodlatte studied government at Bates College in Maine and earned a law degree from Washington and Lee University. He likes to visit the homes of former presidents of both parties.

He ran for Congress in 1992 — with the help of Tim Phillips, now president of Americans for Prosperity — on a promise to serve only 12 years. He later abandoned the pledge, saying everyone must agree to term limits for the policy to work.

As Judiciary Committee chairman, he rejected calls from within his party to try to impeach President Barack Obama and the IRS commissioner, saying there was insufficient evidence.

Goodlatte said he was proud of his work on the USA Freedom Act, which kept phone data out of government hands and revised federal government surveillance practices, and the Permanent Internet Tax Freedom Act, which affirmed the ban on Internet taxes.

He recently co-sponsored a bill introduced by Rep. Barbara Comstock (R-Va.) that would expand the authority of the federal government to deport or detain noncitizen immigrants who are gang members or suspected of gang activity.

The legislation, a response to an increase in killings perpetuated by the MS-13 gang, was panned by the American Civil Liberties Union and immigrant right groups.

In a speech on the House floor, Goodlatte said whether immigrants are here illegally or have visas or permanent resident status, “it is time to send the message that this behavior simply will not be tolerated.”

Surveying Goodatte’s service, Mark J. Rozell, dean of the Schar School of Policy and Government at George Mason University, said the political climate is discouraging incumbents at the state and federal level.

“Members not only have to worry about challenges from the opposing party but a growing level of opposition from within their party if they are not complete purists on every issue,” he said. For that reason, he said, it’s understandable if members “become frustrated and say, ‘I don’t need this anymore.’ ”

The Virginia delegation has been losing clout in recent years through the retirement or defeat of senior members. In addition to Cantor’s loss, Democrat James P. Moran and Republican Frank R. Wolf retired in 2014. Reps. Scott Rigell (R) and Robert Hurt (R) declined to seek reelection last year, the same year Rep. J. Randy Forbes (R) lost his seat in a primary after switching districts.

Rep. H. Morgan Griffith (R-Va.), who has been friends with Goodlatte since the 1980s, said he’ll miss his colleague but that the job isn’t meant to last a lifetime.

“Every politician has a shelf life,” he said, “it’s just different for everybody.”