WASHINGTON — A day after President Trump officially racked up enough delegates to become the presumptive 2020 Republican nominee for president, former Gov. William F. Weld of Massachusetts, his last Republican challenger, ended his campaign.

“The reason that people all over the world look to the United States for leadership, as they do, is our dedication to the rule of law under our Constitution,” Mr. Weld said in a statement announcing the suspension of his campaign. He did not address Mr. Trump by name, but he added that if a president does not observe the rule of law, “we will truly have lost our compass.”

Mr. Weld’s announcement came in the midst of the coronavirus pandemic, and aides said he planned to make no appearances or conduct any interviews because he did not want to distract from coverage of the crisis.

Brad Parscale, the president’s campaign manager, on Tuesday night credited Mr. Trump’s victory in the primary to “his response to the coronavirus and a “broad and strong economy,” even as markets plunged and a global recession appeared inevitable.