Whether you face off against
Palkia or
Dialga depends on your decisions during the story. These Pokémon have slightly different stats, battle moves, and weaknesses. Luckily the boss battle is the same for both! This is the most difficult boss battle to date. While there are several opportunities to throw Balms during the fight, you need to hold ZL for a bit longer, and aim up a bit above
Palkia or
Dialga to gain range and hit your target. Stand back at the start of the fight as
Palkia and
Dialga like to open with a roar that does AoE damage. Alternatively, you can use Y to dodge the roar to avoid damage.
The following explanation focuses on
Palkia as that's what we got for our playthrough, however the moves (Roar, Meteor, etc) are the same for
Dialga. Check the battle section for more details on the differences!

Most commonly, the Counterpart begins its sequence with a meteor move. Its shoulder glows, a large orange circle appears below your character, then after a delay a meteor lands leaving a fire puddle for a short duration. Typically it fires 4 meteors.

The Counterpart follows the meteor move with a wave move. It generates 3 shockwaves which expand outward.

As its health gets lower, the Counterpart begins using a meteor line attack. Functionally, this is identical to the meteor sequence, and is also followed up by shockwaves. But since it's a line you should prioritize moving left/right to avoid the projectiles.

As the fight continues, the Counterpart roars summoning 4 floating orbs. Then it begins to charge up a massive explosion while meteors rain down.
Palkia is weak to both
Dragon and
Fairy moves. It's hard to 1-shot due to having well-rounded stats.
Dialga is a great counter. Alternatively you can use a strong
Fairy type like
Gardevoir. Be prepared to tank a couple hits during the battle. This is the easier of the two options, as
Palkia has more weaknesses than
Dialga.
Dialga resists most types of damage. It is weak to
Fighting and
Ground moves and has lower Sp. Def than Def. Watch out for its Roar of Time.
Lilligant is a solid counter who can take advantage of the
Fighting weakness without taking too much damage. Alternatively you can use a tanky Pokémon like
Ursaluna and grind
Dialga down.
From there, continue dodging, throwing balms when you can and chipping away at the golden bar. If you managed to land most of your balms you may only need to do 1 stun sequence. Otherwise it could take 2-3, use a
Hyper Potion on your Pokémon if it needs healing! Once you deplete the golden bar, you automatically use the
Origin Ball to capture
Palkia or
Dialga.
Pro Tip: After completing the Mission and rolling credits, speak to Professor Laventon in the Galaxy Team HQ to get whichever starters you didn't pick at the beginning of the game.