PARIS — In France’s most consequential election in recent history, voters on Sunday chose Emmanuel Macron and Marine Le Pen to go to a runoff to determine the next president, official returns showed. One is a political novice, the other a far-right firebrand — both outsiders, but with starkly different visions for the country.

The result was a full-throated rebuke of France’s traditional mainstream parties, setting the country on an uncertain path in an election that could also decide the future of the European Union.

It is the first time in the nearly 59-year history of France’s Fifth Republic that both of the final candidates are from outside the traditional left-right party structure. Together, they drew less than half the total votes cast in a highly fractured election.

Even before the official tallies were announced, the political establishment was rallying behind Mr. Macron, warning of the dangers of a victory by Ms. Le Pen’s far-right National Front, though few analysts give her much of a chance of winning the May 7 runoff.