WASHINGTON — For the past two years, Republican senators facing re-election have very deliberately spent millions of dollars, hired multiple consultants and cast scores of conservative votes with one goal in mind: avoiding the embarrassing primary conflagrations that befell their party in 2010 and 2012 and cost Republicans a chance at taking back the Senate.

It has not worked. Despite their careful efforts, some of the best-known and most influential Republicans in the Senate have been unable to shake threats from the right and have attracted rivals who portray these lawmakers as a central part of the problem in Washington.

In Kentucky, Mitch McConnell, the party’s Senate leader, is fending off a charismatic and wealthy conservative challenger. In South Carolina, Lindsey Graham, one of the Senate’s most reliably conservative voices on foreign policy, is being painted by primary opponents as a veritable clone of President Obama.

In Tennessee, Tea Party activists have vowed to take out Lamar Alexander, the veteran senator, former cabinet officer and two-time presidential candidate. “Senator Alexander has never been a true conservative,” said Ben Cunningham, president of the Nashville Tea Party. “His support for the amnesty bill has caused great problems for us,” he said, referring to the Senate immigration bill. “He is at best a moderate.”