BOSTON—A little-known Republican shook up the balance of power in Washington by winning a U.S. Senate seat in Massachusetts, a result that imperils President Barack Obama's top legislative priorities and points to trouble for his party in this year's elections.

With 99% of the vote counted, Republican Scott Brown was leading his opponent, Massachusetts' Democratic Attorney General Martha Coakley, 52% to 47%, according to the Associated Press, which declared Mr. Brown the winner.

The...