By the book, it's the responsibility of the air marshals (if available) then the cabin crew, but in reality able-bodied passengers are usually involved to help. Usually police officers, firemen, etc. (if were around) volunteer to help without asking them after identifying themselves.
Why are passengers involved? it's actually allowed for cabin crew to ask for the help of the able-bodied passengers in cases of emergencies, unruly passenger is an emergency.
Regarding flight deck crew, policy usually requires them to lock the flight deck door for any kind of access in such cases until things are cleared out to make sure it's not some sort of a diversion to allow potential associates to do a more serious offense, that is hijacking! By locking flight deck door I mean even authorized cabin crewmember(s) will not be able to access using the designated code, which they can in normal cases.
Once there's an unruly passenger onboard, there's a form to be filled by the senior cabin crew and signed by the captain to be handed to the authorities after landing. The captain will usually contact the nearest airport once the case is reported by cabin crew, then the captain will decide whether to land immediately in the nearest airport or to continue the flight. Either way, the passenger will be handed to the airport security once landed. Usually passengers will be requested to hold deplaning until security has detained the unruly passenger.
Source: I'm a cabin crewmember.