The invention discloses a method for preparing hydrocarbon from higher aliphatic ester by taking metal phosphide as a catalyst. The method comprises the following steps: filling the metal phosphide catalyst in a fixed bed reactor; feeding in the molar ratio of hydrogen to higher aliphatic ester of (10-500):1; under the conditions that the temperature is 250-450DEG C and H2 pressure is 0.1-8.0MPa and the weight hourly space velocity of higher aliphatic ester is 0.1-15h<-1>, generating hydrocarbon, wherein the metal phosphide catalyst takes silicon dioxide, aluminum oxide, HY molecular sieve, HZSM-5 molecular sieve, titanium dioxide-aluminum oxide composite oxide or cerium oxide-aluminum oxide composite oxide as a carrier, the active phase of hydrocarbon is phosphide of Ni, Co, Fe, Mo, W, Ni-Co, Ni-Fe, Ni-MO, Ni-W or Co-Mo, and the mass of the metal element and the mass of the phosphorus element respectively account for 30-40wt% and 1-15% of that of the catalyst. According to the invention, the adopted metal phosphide catalyst has the advantages of high activity, low cost, good application prospect and the like and does not need to use a vulcanizing agent.