WASHINGTON — Representative Tim Murphy, Republican of Pennsylvania, announced Wednesday night that he would not seek re-election in 2018 after a backlash over reports that he had suggested to his lover to consider having an abortion.

In a statement, Mr. Murphy, 65, an outspoken opponent of abortion who has served in the House since 2003, said his decision to retire came after discussions with his family and staff. Mr. Murphy was uncontested in his 2016 campaign for the heavily Republican district in western Pennsylvania that includes parts of Pittsburgh.

“In the coming weeks I will take personal time to seek help as my family and I continue to work through our personal difficulties and seek healing,” Mr. Murphy said in the statement. “I ask you to respect our privacy during this time.”

Mr. Murphy, who is married with an adult daughter, admitted several weeks ago to having an extramarital affair with Shannon Edwards, a forensic psychologist, that began in 2016. The allegations surfaced after a court unsealed records in the divorce case between Dr. Edwards, 32, and her former husband.