WASHINGTON — Tashfeen Malik, who with her husband carried out the massacre in San Bernardino, Calif., passed three background checks by American immigration officials as she moved to the United States from Pakistan. None uncovered what Ms. Malik had said online about her views on violent jihad.

She said she supported it. And she said she wanted to be a part of it.

American law enforcement officials said they recently discovered those old — and previously unreported — communications as they pieced together the lives of Ms. Malik and her husband, Syed Rizwan Farook, trying to understand how they pulled off the deadliest terrorist attack on American soil since Sept. 11, 2001.

Had the authorities found the messages years ago, they might have kept her out of the country. But their recent discovery exposed a significant — and perhaps inevitable — shortcoming in how foreigners are screened when they enter the United States, particularly as people everywhere talk more and disclose more about themselves online. Despite a tremendous electronic intelligence-gathering apparatus that captures phone calls and emails from around the world, it remains impossible to conduct an exhaustive investigation for each of the tens of millions of people who are cleared each year to come to this country to work, visit or live.

Federal officials said they had discovered private conversations about jihad between Ms. Malik and Mr. Farook on an online messaging platform, as well as emails and communications on a dating site, but not on traditional social media sites such as Facebook. But even those sites, where conversations can be public or semipublic, pose a logistical hurdle for immigration screeners, who do not routinely conduct social media searches during the visa process.