Police said the attack happened at a property in Straham View in Dervock, near Ballymoney, shortly after 00:30 GMT. One of the masked men was armed with a handgun. The group then made off in a Toyota Yaris, which was later found burnt out on Burnquarter Road.
Three other people who were in the house at the time were uninjured but left badly shaken, police said.
"Officers along with colleagues from the Northern Ireland Ambulance Service attended and the man was taken to hospital for treatment for his injuries," Det Inspector Ballentine from the Police Service of Northern Ireland (PSNI) said.
Police are appealing for witnesses.