The bomb wasn’t the only thing burning in his pants.

Internet postings from accused knicker-bomber Umar Farouk Abdulmutallab reveal him to be a sex-starved, lonely, depressed man who felt shame over his carnal urges.

“As i get lonely, the natural sexual drive awakens and i struggle to control it, sometimes leading to minor sinful activities like not lowering the gaze [in the presence of unveiled women],” a poster who goes by the handle “Farouk1986,” wrote on an Islamic Forum Web site, gawaher.com.

“And this problem makes me want to get married to avoid getting aroused . . .

“But i am only 18 . . . It would be difficult for me to get married due to social norms of getting to the late 20’s when one has a degree, a job, a house, etc before getting married.”

No matter how difficult it was to balance his Muslim and secular worlds — he was tortured about his “dilemma between liberalism and extremism” — Abdulmutallab always brought the discussion back to his most pressing dilemma: sexual desire.

“The hair of a woman can easily arouse a man,” Farouk wrote, one of hundreds of entries posted between 2005 and 2007.

“The Prophet advised young men to fast if they can’t get married but it has not been helping me much and I seriously don’t want to wait for years before I get married.”

For Abdulmutallab, 23, even his fantasies were steeped in carnal conflict, highlighted by an inner battle between good and evil.

“So usually my fa[n]tasies are about islamic stuff,” he continued. “The bad part of it is sometimes the fantasies are a bit worldly rather than concentrating in the hereafter.”

He was also agonized about going to his prom.

“Like sister MM 04 suggested, an islamic party is good, a great way to spend your last moments in school with good people,” he wrote on May 7, 2005.

“Guys in my school talk and plan what they will do for their proms years in advance, organising their dates, cars, suits and what not,” he added, referring to the “peer pressure.” “My answer to this is, be patient.”

Abdulmutallab stopped just short of reaching the hereafter when a bomb he had hidden in his drawers failed to explode aboard a Detroit-bound flight on Christmas Day.

The suspect was wearing briefs with a specially tailored pouch packed with 80 grams of PETN, a key ingredient of a plastic explosive powerful enough to blow a hole in the side of the plane.

Authorities said the Nigerian man tried to detonate it with acid from a hypodermic needle but only singed his shorts.

Abdulmutallab’s Internet rants seemed less like those of a terrorist-in-the-making and more like a young man burdened by loneliness and a desperate need to be understood.

“i am in a situation where i do not have a friend,” one screed read. “i have no one to speak too, no one to consult, no one to support me and i feel depressed and lonely. i do not know what to do.”

He also told members of an online forum that he was lonely at a British boarding school in the West African nation of Togo because few of his classmates were Muslims.

“i get lonely sometimes because i have never found a true muslim friend,” Abdulmutallab wrote. I’m active, I socialise with everybody around me, no conflicts, I laugh and joke but not excessively.

“I strive to live my daily live [sic] according to the quran and sunnah to the best of my ability.”

Farouk1986 discussed growing up and preparing to leave boarding school for college. But his educational pursuits were quickly overtaken by his obsessions with a holy war.

“I imagine how the great jihad will take place, how the muslims will win, insha Allah [God willing], and rule the whole world, and establish the greatest empire once again!!!” reads one post from Feb. 20, 2005.