An intruder demanding to see U.S. House of Representatives Speaker Nancy Pelosi broke into her San Francisco home and attacked her husband with a hammer on Friday, officials said, in an assault that stoked fears about political violence ahead of the November 8 midterm elections, Reuters reported.

Paul Pelosi, 82, was taken to a San Francisco hospital where he underwent surgery for a skull fracture and injuries to his right arm and hands, a spokesperson for the House speaker said in a statement. Doctors expect her spouse to make a full recovery, the statement said.

The man arrested at the scene was identified as David Depape, 42, who was also taken to a hospital.

Depape was booked into the San Francisco County Jail on suspicion of attempted murder, assault with a deadly weapon, elder abuse, battery, burglary, and other felonies.

Authorities were still investigating a motive for the predawn attack.

The incident came less than two weeks before midterm elections that will decide control of the House and U.S. Senate, in the midst of a highly polarized political climate.

CNN reported that Paul Pelosi had called emergency-911 and spoke in "code," not saying directly that he was under attack but leading the dispatcher to conclude something was wrong.

Politico, citing a person familiar with the situation, reported separately that Pelosi had told the intruder he needed to use the bathroom, and then furtively called 911 from there, where his cellphone had been charging.

The intruder shouted "Where is Nancy?" before attacking her husband, a person who was briefed on the incident told Reuters.

In recent posts on several websites, an internet user named "daviddepape" expressed support for former President Donald Trump and embraced the cult-like conspiracy theory QAnon. The posts include references to "satanic paedophilia," anti-Semitic tropes and criticism of women, transgender people, and censorship by tech companies.

Reuters could not confirm that the posts were created by the man arrested on Friday.