I think this is what happened.
The men travelling with stolen passports accessed the cockpit and forced the pilot to change course and shut off the transponder, the device that constantly identifies the plane and reports its location to airports and other planes.
There may have been someone else on the plane helping the hijackers, perhaps a staff member.
The pilots resisted, and a fight ensued. The plane plunged into the sea.