Hagrid's capture occurs (in the novel, at least) during the Battle of Hogwarts.
‘HAGRID, COME BACK!’
But he was not even halfway to Hagrid when he saw it happen: Hagrid vanished amongst the spiders, and with a great scurrying, a foul swarming movement, they retreated under the onslaught of spells, Hagrid buried in their midst.
‘HAGRID!’
Harry heard someone calling his own name, whether friend or foe he did not care: he was sprinting down the front steps into the dark grounds, and the spiders were swarming away with their prey, and he could see nothing of Hagrid at all.
‘HAGRID!’
He thought he could make out an enormous arm waving from the midst of the spider swarm, but as he made to chase after them, his way was impeded by a monumental foot, which swung down out of the darkness and made the ground on which he stood shudder. - Harry Potter and the Deathly Hallows
Although we don't see his capture, we can make the assumption that once he was outside the Great Hall he was simply taken by the Death Eaters under Voldemort's command.