CARACAS, Venezuela — President Nicolás Maduro of Venezuela faced the most direct challenge to his hold on power on Wednesday, when an opposition leader stood in the streets of the capital and declared himself the legitimate president, cheered on by thousands of supporters and a growing number of governments, including the Trump administration.

Mr. Maduro responded furiously by cutting diplomatic ties with the United States. He gave American diplomats 72 hours to leave the country, ordering them out with a derisive “be gone!” and accusing the Trump administration of plotting to overthrow him. The United States said it would ignore the deadline.

The fast-moving developments convulsed Venezuela, a once-prosperous country that has been devastated by years of political repression, economic mismanagement and corruption. But they also appeared to give new momentum to the opposition leader, Juan Guaidó, the 35-year-old National Assembly leader who stepped onto the national stage just recently.