LIMA, Peru — Martín Vizcarra, who had been Peru’s first vice president and ambassador to Canada, was sworn in as the nation’s president on Friday afternoon, after Congress accepted the resignation of his predecessor, Pedro Pablo Kuczynski, who was brought down by scandals involving graft, vote-buying and a looming impeachment.

In his inaugural speech, Mr. Vizcarra said this was “a difficult moment” for the country.

“The time has come to say we’ve had enough,” Mr. Vizcarra said. “Any type of irregularity must be punished accordingly and justice must act with independence, responsibility and speed. But at the same time, what has happened must mark the end point of a policy of hatred and confrontation.”

Earlier Friday, 105 of 130 lawmakers voted to accept the letter of resignation that Mr. Kuczynski offered on Wednesday, in which he admitted no wrongdoing and accused lawmakers of obstructing his administration.

Legislators also passed a resolution, in which they said they “deplore and reject” the language that Mr. Kuczynski used to resign and held that “the current political crisis is the result of acts that the president himself has committed.”