A sign at a demonstration coinciding with President Trump's visit to El Paso last month after the mass shooting there. (Mario Tama/Getty Images)

From the White House lawn on Sunday, President Trump promised a package of laws to address the scourge of gun violence.

But in advertisements that went up Monday on Facebook, the president delivered a very different message, pointedly warning a select group of voters that Democrats were intent on repealing the Second Amendment and asking them to sign their names to a petition to defend gun rights.

“Democrats have finally admitted what they truly want: a repeal of the Second Amendment,” reads one variation of the ad, which went up two days after a shooting attack Saturday in two Texas towns left seven dead and 22 wounded. “It’s up to the American people to stand strong and defend our freedoms.”

The appeal went out as a Trump surrogate — a member of his 2020 advisory board — promoted a conspiracy theory on Twitter falsely tying the Saturday gunman to Beto O’Rourke, a former Texas congressman and presidential candidate.

The Facebook blitz, which relies on misleading claims about Democratic objectives, offers a window into Trump’s mixed messaging on guns in the wake of a pair of mass shootings in early August — in El Paso and in Dayton, Ohio — that marked the nadir of a bloody month in which more than 50 people were killed in mass gun attacks.

In the days after the El Paso shooting, Trump signaled he was open to proposals for new background checks, saying that “there is a great appetite” for such measures. Soon after, following a phone call with National Rifle Association head Wayne LaPierre, the president changed his tune, echoing the messaging of the NRA.

Last weekend, Trump again embraced the NRA’s talking points, asserting that background checks would “not have stopped any of it.” Still, he said, “we’re doing a package, and we’ll see how it comes about.” Mum on details, he said, “We’re looking at a lot of different bills, ideas, concepts."

The ads illuminate how targeting techniques offered by Facebook and other platforms allow Trump to sound one note from the White House lawn and a different note to a handpicked group of Internet dwellers. The base gets one message; everyone else gets another.

Some versions include a video with foreboding music and a promise that “Your Second Amendment will NEVER BE REPEALED.” An invitation to sign what the ads bill as the “Official Defend the Second Amendment Petition” flashes in red. Users who comply are asked to enter their names, email addresses and Zip codes, with the option to add a mobile number.

The ads, sponsored by Trump’s official Facebook page, were paid for by the Trump Make America Great Again Committee, a joint national fundraising committee run by the Trump campaign and the Republican National Committee.

“The messaging [of the ads] is straight from the NRA playbook, painted in as dire and apocalyptic terms as they can muster,” said Robert Spitzer, a political scientist at the State University of New York at Cortland. “To the extent that he’s been oscillating back and forth and making sympathetic noise about a number of different proposals, this abandons all of that.”

The ads were targeted at users across a broad swath of the country but appeared to be concentrated in certain left-leaning states with a sizable population of gun owners, such as Oregon and Washington, as well as a handful of Midwestern states, including Michigan and Ohio.

One version appears only to men between the ages of 45 and 54 in Louisiana, which is exceptionally specific, said Laura Edelson, a researcher at New York University’s Tandon School of Engineering who studies advertising on social media. She speculated that it was an attempt to collect personal identifying information from attendees of a single event, such as a gun show.

Spitzer said the ads amounted to a “rallying cry for the gun base,” delivered two days after a deadly shooting and as prominent Democrats pressed the case for gun control. That environment provides fertile ground for dire warnings about the Second Amendment, he said, because of anxiety that spikes about lawmakers reining in access to firearms.

The Trump campaign did not respond to a request about the timing of the ads and whether they were specifically tied to fresh calls for gun control after the shooting in West Texas. Also unanswered was a question about the accuracy of saying Democrats want to repeal the Second Amendment, which is not a pathway publicly favored by any Democratic presidential aspirants or member of Congress.

Reexamining the Second Amendment has gained currency among a small group of state lawmakers and candidates for federal office. Hawaii Democrats introduced a measure in March urging Congress “to clarify the constitutional right to bear arms.” And Shannon Liss-Riordan, who is challenging Sen. Edward J. Markey of Massachusetts in the Democratic primary, last month said it was “time we take real action and repeal the Second Amendment.”

John Paul Stevens, a Republican who served on the Supreme Court for 35 years, in March made the case for the Second Amendment’s repeal in a New York Times op-ed. (Stevens died in July.)

Facebook did not return a request for comment about whether the characterization of Democratic priorities violates its policy against “deceptive, false, or misleading content.”

The Trump campaign has spent massively on Facebook in recent months, including about $5 million since the start of June, according to data compiled by Bully Pulpit Interactive, a Democratic communications agency. But it has not been a top Facebook spender on ads related to guns and gun control. Among top-tier Democratic presidential candidates, Sen. Elizabeth Warren (D-Mass.) was alone in putting out new ads about gun control after the weekend violence.

Other groups that have come out with fresh gun-related ads on Facebook after Saturday’s shooting included Washington Gun Law, an advocacy group that promises to “keep you apprised of all relevant legal issues involving firearms and self-defense in Washington state,” and U.S. & Texas LawShield, a legal-defense organization.

Social media was awash in misinformation about guns and gun control after Saturday’s shooting, which unfolded in Odessa and Midland.

Much of the false messaging targeted O’Rourke, who has called for mandatory buybacks of assault weapons, among other measures to curb the violence that has convulsed scores of American cities, including his hometown of El Paso.

Anthony Shaffer, a former Defense Intelligence Agency officer and a member of Trump’s 2020 advisory board, on Monday promoted a conspiracy theory falsely claiming that the gunman in West Texas was an O’Rourke supporter, with a sticker on his truck supporting the candidate — claims for which there is no evidence, authorities confirmed.

Shaffer, who has promoted baseless claims about the 2012 attacks in Benghazi, Libya, and clashed with the U.S. military and intelligence communities over his allegations of an intelligence failure before the attacks of Sept. 11, 2001, took to Twitter after the shooting to assail Democrats for calling for new restrictions on firearms. In one post, he said the gunman was a supporter of O’Rourke, tagging the Democrat, and retweeting a post from an account with the handle @suemo54 and the name “Sue Moore.”

The original tweet, posted Sunday, read: “The Odessa Shooter’s name is Seth Ator, a Democrat Socialist who had a Beto sticker on his truck.” It had garnered more than 10,000 retweets by early Tuesday, despite being previously flagged to Twitter.

Oscar Villarreal, a spokesman for the Texas Department of Public Safety, said there was no indication the gunman was linked to O’Rourke in any way. Nir Hauser, a co-founder of a firm called VineSight, which uses artificial intelligence to track misinformation, said the post appears to have been amplified mainly by bot accounts.

Shaffer, in a brief interview Tuesday morning, stood by his tweet, saying “That’s not what I’ve seen from people” when informed that his claim about the gunman had no basis in fact.

He declined to answer questions about his work on Trump’s advisory board, saying only that it was an unpaid role that he has fulfilled “since the time they went into office.” In April, Shaffer was interviewed by Lara Trump, the president’s daughter-in-law, on the Donald J. Trump Podcast.

Responding to an inquiry about Shaffer’s role on the advisory board, the Trump campaign said: “The Trump 2020 Advisory Board is a diverse group of key supporters committed to reelecting President Donald Trump. Advisory Board members often serve as surrogates in media appearances or by writing op-eds.”

The account that appears to have hatched the conspiracy theory about O’Rourke, drawing Shaffer’s attention, identifies its owner as a 72-year-old retiree living in Mesa, Ariz. A message left on a linked Facebook page went unanswered Tuesday.