BRUSSELS — After grueling and bitter negotiations, the European Union on Tuesday finally decided on the heads of its key institutions, making history by putting forward two women for the most important jobs at a moment when the bloc’s unity is being tested as never before.

After the sort of exhausting, grinding process for which the bloc is now infamous, European leaders nominated two conservatives, the German defense minister, Ursula von der Leyen, as Commission president, and the French head of the International Monetary Fund, Christine Lagarde, as head of the European Central Bank.

They ascended weeks after a new Parliament was elected that saw the larger parties losing ground to smaller, more ideological ones, testing the limits of the bloc’s need for consensus among 28 members that are increasingly divided — West versus East, conservative versus progressive, federalist European versus populist.

Ultimately, the negotiations were about papering over those differences. If it was messy, the haggling also underscored how the European Union matters more as the bloc struggles to respond to the challenges of migration, climate change, President Vladimir V. Putin of Russia, inequality and the rise of populists.