In this photo taken on Aug. 9, 2014, Alaska Republican U.S. Senate hopeful Dan Sullivan addresses supporters at a campaign event in Juneau. (AP Photo/Becky Bohrer)

Former state attorney general Dan Sullivan won the Republican nomination for U.S. Senate in Alaska on Tuesday, setting the stage for a competitive showdown against Sen. Mark Begich (D) in one of the most important contests in the battle for the Senate majority.

Sullivan's primary was effectively the final test for Senate Republicans ahead of the post-Labor Day period when the general election campaign begins in earnest. His win caps a successful primary season in which no incumbents lost for the first time since 2008 and the party avoided nominating the kind of controversy-prone figures who spoiled their hopes in 2012 and 2010. Republicans are well-positioned to compete for the six seats they need to wrest the Senate majority away from Democrats.

Sullivan defeated tea party activist Joe Miller, Lt. Gov. Mead Treadwell and retired Air Force sergeant John Jaramillo. He rode the support of a coalition of tea party and establishment Republican groups to victory. Sullivan outspent and outraised his competitors by a wide margin.

With nearly all precincts reporting, Sullivan led Miller 40 percent to 32 percent. Treadwell placed third with 25 percent and Jaramillo finished a distant fourth. The Associated Press has called the race for Sullivan.

The former attorney general will now turn his full attention to Begich, a first-term senator who polls show is vulnerable. Begich, the son of the late congressman Nick Begich, has run a campaign rooted in emphasizing his record on local issues and his family's deep ties to the state. A super PAC supporting him has run ads portraying Sullivan, who was raised in Ohio, as an outsider falsely touting his Alaska credentials.

Sullivan and his allies, which include the anti-tax Club for Growth and the U.S. Chamber of Commerce, two well-funded groups that have clashed in other races, have tied Begich to President Obama, who is deeply unpopular in Alaska. They've run ads noting his support for the president's policies, including the federal health-care law.

Both candidates have tried to to shield themselves from the attacks the other side has lobbed with positive commercials of their own. Sullivan has enlisted the support of his wife, an Alaska native, to burnish his argument that he understands the state well. She appeared in a July ad.

Sullivan moved to Alaska in 1997 and spent much of the next decade living in suburban Washington while working in George W. Bush's administration. In between, he was recalled to active military service.

Begich has tried to put distance between himself and Obama. He refers to himself as a "thorn in his [posterior]."

A nasty television ad war is expected to sweep across the state in the fall. Air time in sparsely populated Alaska is cheaper than in most states, leading the candidates and outside groups to buy up virtually all the fall commercial time well in advance of Labor Day.

In addition to attacks on his residency, Democrats also plan to try to tie Sullivan to Palin, who was governor when he was attorney general.

Begich is one of four Democratic senators running for reelection in a state Mitt Romney won in 2012. If he can hold his seat, it will significantly boost Democratic chances of holding their fragile majority.

Sullivan's victory came over Republicans seen as less equipped to take on Begich in the fall. Treadwell struggled to raise money desipte his status as a statewide elected official. Miller, a far-right conservative, was the Republican nominee in 2010, surprisingly defeating Sen. Lisa Murkowski (R) in the primary. But he ran a disastrous general election campaign and lost to Murkowski, who ran as a write-in candidate.

Democrats meddled in the race in an apparent attempt to elevate Miller, running an ad late in the race critical of his opponents. Miller received a late endorsement from Sarah Palin, the former Alaska governor and 2008 vice presidential nominee.

But Sullivan, long viewed as the favorite, held his ground. Treadwell, who ran an underwhelming campaign that underwent a staff shakeup earlier this year, never really emerged as a real threat.