A former governor of Massachusetts has become the first Republican to challenge President Donald Trump for the nomination for US president in 2020.

William Weld, 73, said in announcing his candidacy that “it is time to return to the principles of Lincoln — equality, dignity and opportunity for all”.

He said, “There is no greater cause on earth than to preserve what truly makes America great. I am ready to lead that fight.”

Mr Weld has accused Mr Trump of leaving the nation in “grave peril” and has said his “priorities are skewed toward promotion of himself rather than for the good of the country”.

While Mr Trump’s overall approval ratings have been poor for much of his presidency, he remains popular with Republican voters.

The Republican National Committee (RNC) in January issued a nonbinding resolution to declare the party’s undivided support for Mr Trump.

The move by Mr Weld makes Mr Trump the first incumbent president since George HW Bush in 1992 to face a notable primary challenge.

Mr Trump’s campaign has taken extraordinary steps in cementing control over the RNC and the broader nomination process as it seeks to minimise the risk of any potential challenger doing the same to the president.

Donald Trump remains popular with Republican voters (Andrew Harnik/AP)

His campaign recently reported raising 30 million dollars in the first quarter of this year, while Democrats are raising less money than in previous cycles.

Fiscally conservative but socially liberal, Mr Weld is known for an unconventional, at times quirky, political style and a long history of friction with the party he now seeks to lead.

Mr Weld endorsed Democrat Barack Obama over Republican nominee John McCain in 2008, later saying it was a mistake to do so, and has enjoyed a decadeslong friendship with the Clintons, which began early in his career when he served alongside Hillary Clinton as a lawyer for the House Judiciary Committee during the Watergate proceedings.

With little in the way of organisation or outside money, and at odds with a majority of Republican voters who solidly support Mr Trump, Mr Weld’s longshot campaign will target disaffected Republicans and independents who share his disdain for the president and embrace libertarian values of small government, free trade and free markets, and personal freedom.

Despite a pledge to libertarians that he would remain loyal to the party going forward, Mr Weld on January 17 walked into the clerk’s office of the Massachusetts town where he lives and re-registered with the Republican Party, adding to speculation that he would challenge Mr Trump in the primaries.

Mr Weld has not won a political race since being re-elected governor by a landslide in his heavily Democratic state in 1994.

He was first elected to the office in 1990, defeating a conservative Democratic candidate, and quickly became one of Massachusetts’ most popular governors in recent history.