As mortally wounded NYPD cop Wenjian Liu lay in a Brooklyn hospital in 2014, doctors asked his stricken wife if she wanted his semen preserved so that she might someday have his child.

“Of course she said yes,’’ a friend told The Post — and Tuesday, two-and-a-half years after Liu’s murder, his widow gave birth to their daughter.

Liu’s widow, Pei “Sanny’’ Xia Chen, named the baby “Angel’’ as a tribute to her slain hero husband — whose police hat is now next to her bed at New York-Presbyterian Hospital on the Upper East Side, said the pal, fellow cop widow Maria Dziergowski.

The day Chen was artificially inseminated, “she had a dream that Wenjian was there in a white gown looking like an angel and that he handed her a baby, and he said, ‘It’s a girl, a little angel,’ ’’ Dziergowski said.

“So [Chen] knew before everyone that it was a girl.

“The baby’s adorable, smiling, laughing,’’ added Dziergowski, who was with Chen at the hospital Tuesday. “She has a lot of hair, a lot of black hair.’’

Chen — who had only been married to her policeman husband for three months before he and his partner were killed in an ambush by a cop-hating madman — was admitted to the hospital around 12:30 p.m. Monday and gave birth at 4:35 a.m., Dziergowski said.

The baby, whose full name is Angelina, weighed 6 pounds, 13 ounces and is 19.5 inches long, Dziergowski said.

Sources said the baby’s birth was particularly poignant for Liu’s parents, who lost their only son, 32, in the double murder.

Liu’s dad and mom, who live in Brooklyn, went to the hospital to see their new granddaughter hours after her birth, Dziergowski said.

“The parents were very emotional, crying and holding the baby,” she said.

Liu and NYPD partner Rafael Ramos were sitting in their patrol car in Brooklyn on Dec. 20, 2014, when crazed killer Ismaaiyl Brinsley walked up to their vehicle and fatally shot them. Hours earlier, Brinsley wrote on Instagram, “I’m Putting Wings on Pigs Today.’’ He later committed suicide.

Liu and Ramos died at Woodhull Hospital — and “that night, the doctors came to [Chen], and they asked her if she wanted them to harvest his sperm,’’ Dziergowski said.

A beaming Chen spent Tuesday cradling their newborn daughter every chance she could get, the friend said.

In her eulogy to her husband, Chen called Liu “my hero.’’

She later said she wears his police badge every day.

Liu was 12 when he and his parents emigrated to the US from Guangzhou, China, in 1994. He and Chen were living with his parents at the time he was killed.

At Liu’s funeral, his weeping father, Wei Tang Liu, told mourners through a translator, “Today is the saddest day in my life. My only son has left me.’’

Female cops and friends of Chen poured into the hospital Tuesday to congratulate the mother and child, Dziergowski said.

The group threw her a baby shower about two weeks ago, the friend said.

Dziergowski met Chen as part of the NYPD’s extended family of police widows.

She was three months pregnant with her second child when her husband, NYPD Officer Matthew Dziergowski, was killed Feb. 14, 1999, by a drunken driver. The hero cop had been guarding the scene of a car accident in Staten Island at the time.

Maria named the baby Matthew after his father.