The Republicans have retained a Congressional seat in Arizona, but with a single-digit margin in the usually deep-red state.

Debbie Lesko beat her Democratic rival by only about five percentage points.

The vote was seen as a test of President Donald Trump's Republican party in a district where he won by a margin of 21 points in 2016.

Correspondents say this should have been the easiest of wins for them. It comes months before mid-term elections.

The special election in the 8th congressional district - in the greying, conservative suburbs of the state capital, Phoenix - was called when the incumbent, Trent Franks, was forced to resign in December over sexual misconduct.

The Republicans poured money into the race, President Trump was roped in to provide support by telephone and Twitter, and the candidate was experienced, says the BBC's North America correspondent James Cook.

Ms Lesko is a vocal supporter of Mr Trump's proposed border wall with Mexico. She was up against political newcomer Hiral Tipirneni, a former emergency room doctor, who campaigned for expansion of the Medicare national social insurance programme.

'Too close'
"I've really come a long way and this is really quite overwhelming, it's very surreal," Ms Lesko said at a victory party, according to the Associated Press (AP) news agency.

But Ms Tipirneni - who has not yet conceded defeat - adopted an ebullient tone on Twitter, pledging to contest the seat once again in November.

And Republicans took note of the implications of the result for November's legislative elections.

"They should clean house in this election," Chuck Coughlin, adviser to former Arizona Gov Jan Brewer, told AP.

"There's a drag on the mid-terms for Republican candidates that's being created by the national narrative. And it would be very hard to buck that trend if you're in swing districts, much less close districts, if you can't change that narrative between now and November."

A senior, unnamed Republican told CNN that the contest "was not supposed to be this close".

"We really can't blame anything. We got killed among independents," the person said.

A newly energised Democratic movement has helped secure a string of recent upsets for the party, including a Senate seat in Alabama, victories in New Jersey and Virginia, and Democrat success after a cliffhanger congressional election in Pennsylvania.