Image copyright Reuters Image caption Congressman Eric Cantor will step down from his House leadership position

US Republicans are reeling after House Majority Leader Eric Cantor lost his primary election to a challenger from the party's populist Tea Party wing.

Mr Cantor announced on Wednesday he would step down from his leadership position effective 31 July.

In a shock result, economics professor David Brat defeated the long-time Virginia congressman on Tuesday.

"In the end, the voters chose another candidate," Mr Cantor said, declining to analyse the reasons for his loss.

"Our [Republican Congressional] members are in good positions in their districts," the Virginia Republican told reporters. "I couldn't be more optimistic about the future."

Republican Congressman Dana Rohrabacher of California said Mr Cantor was defeated because his position on immigration reform - he had backed a Democratic proposal to allow young people brought illegally to the US as children to gain citizenship - contravened his constituents' views.

"He was taking a stand on an issue that his constituents were adamantly opposed to," Mr Rohrabacher told the BBC's Katty Kay.

"Eric didn't understand that. He was a good Republican, but he didn't go out and see that the big business may have wanted that amnesty programme but his constituents didn't want it."

Some Republicans have expressed concern over what Mr Cantor's defeat means for the party, which analysts say is struggling to broaden its appeal beyond its core base of conservative suburban and rural white voters.

"I'm concerned that Ted Cruz supporters, Rand Paul supporters, are going to use this as an excuse" to shut down the government, said New York Congressman Peter King, referring to two of the party's most prominent and bombastic conservatives. "This is not conservatism to me."

Several Republicans have expressed interest in running to succeed Mr Cantor in the party's House leadership, including Kevin McCarthy of California, as well as Pete Sessions and Jeb Hensarling, both of Texas.

Analysis in the US media

Image copyright AP

There's a famous saying by former Speaker of the House Tip O'Neil that "all politics is local".

In the end, Mr Cantor could be out of a job because he took his home-state constituents for granted.

"Cantor let his guard down by focusing on the intrigues of the Capitol and neglecting the demands of district service, constituent contact and visible fealty to local priorities," writes NPR's Ron Elving.

Eric Cantor and the giant slayer

Democrats have jumped on the unexpected defeat as a positive sign for their own chances of regaining control of the House of Representatives this year.

"Tonight, is a major victory for the Tea Party as they yet again pull the Republican Party further to the radical right," House Minority Leader Nancy Pelosi said in a statement. "As far as the midterm elections are concerned, it's a whole new ballgame."

In a forewarning of trouble, last month Mr Cantor was booed at a meeting of Republican activists after a local party chairman whom he supported was removed in favour of a Tea Party candidate.

Mr Cantor had been widely favoured to win, having raised $5.4m (£3.2m) for his campaign, nearly 20 times as much as Mr Brat, who described the win as "a miracle from God".

Image copyright AP Image caption David Brat was a relatively unknown figure before his stunning win

Throughout the race, Mr Brat gained traction by attacking Mr Cantor's record, including his support for some immigration reforms, and rallied enthusiastic members of the anti-tax, conservative populist Tea Party movement in the low-turnout race.

A lawyer, Mr Cantor, 51, was first elected to Congress in 2000 after serving nine years in the Virginia House of Delegates.

After the Tea Party emerged in 2009, he forged ties with the loose-knit movement, drawing on its support to help the Republicans take control of the House of Representatives the following year.

Mr Cantor was seen as representing a conservative counterweight to House Speaker John Boehner, viewed by some in the Tea Party as too willing to negotiate with Democratic President Barack Obama.

Mr Brat will now face Democratic nominee Jack Trammell - also a professor at Randolph-Macon College - in this fall's general election.

Analysis by Mark Mardell, BBC News, Washington

The defeat of the second-most-important Republican in the House at their hands is being variously described as an "apocalyptic moment" and "an earthquake".

I am not sure the Earth has moved for me, but it will make senior Republicans worry they are still on shaky ground.

The victory of the apparently underfunded and little known Prof David Brat will send a message.

The truth is the Tea Party are a force to be reckoned with still.

They've pushed their party to the right, dominated its council for years, and they won't go away after the mid-terms in November.

Tea Party victory - a harbinger