A creature with haste is exempt from the 'summoning sickness' rule that normally prevents a creature from attacking unless it has been under its controller's control since the beginning of that player's most recent turn (CR 302.6). Haste allows the creature to attack and use tap abilities the same turn it enters the battlefield.
The critical timing window is the Declaration of Attackers step (CR 508.1). If the creature has haste at that moment, it is legally allowed to be declared as an attacker. Once it is declared as an attacker, it is attacking — nothing that happens afterward removes it from combat simply because haste later expires.
Effects that last 'until end of turn' don't expire until the cleanup step (CR 514.2), which comes after combat has already concluded. So in practice the creature will have haste all through the combat phase anyway, but even if haste somehow expired mid-combat, the creature would remain an attacker because being removed from combat requires a specific effect that removes it (CR 506.4).
Concrete example: You cast Fires of Yavimaya on your main phase, which gives all your creatures haste until end of turn. You then play a 3/3 creature token. Because it has haste, you declare it as an attacker in your combat phase. Even though haste will wear off in the cleanup step, the creature deals its combat damage normally — the expiration of haste does not undo the attack.
Summary: haste only needs to be present when attackers are declared (CR 508.1a). The later expiration of the granting effect has no impact on the legality or resolution of the attack.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.