Dying rock legend Maurice Gibb of the Bee Gees battled to keep on stayin’ alive — until his twin brother Robin reached his bedside after a desperate 5,000-mile dash from England to Miami.

Then, with Robin, his older brother Barry Gibb and other family members there to comfort him, 53-year-old Maurice took his final breath.

“It was as if Maurice somehow knew Robin was on his way,” a source close to the Gibb family told The ENQUIRER.

It was the second example in less than three days of “twin telepathy” linking the famous siblings. When Maurice collapsed in his Miami Beach home with agonizing stomach pains on January 8, fraternal twin Robin said he felt his pain an ocean away.

“The morning Maurice was taken ill, I had stomach pains for an hour to two hours — at the very time,” said Robin. “It was a discomforting feeling that something wasn’t right — and I hadn’t had any pains like that before.”

Maurice’s collapse “was completely out of the blue,” said his manager Carol Peters. “Just all of a sudden — boom.”

The singing star was rushed to Mount Sinai Medical Center where he initially suffered cardiac arrest before abdominal surgery was performed to remove an intestinal blockage.

The worst seemed to pass and Barry Gibb, three years older than his twin brothers, kept in touch with Robin by phone, assuring him there was no need to immediately fly to Miami.

But by Saturday, January 11, Maurice had sunk into a coma. With hope fading, Robin raced to the airport to catch a British Airways flight.

“The flight was delayed and came in nearly an hour late,” said the close family source. “Robin now knew how close to death Maurice was, so you can imagine his feelings as the plane fell behind schedule.”

Looking drawn and haggard, he arrived at the hospital before 9:30 p.m. and was immediately taken to the intensive care unit where his brother lay dying, joining brother Barry, Maurice’s wife Yvonne and their children Adam and Samantha.

“They were all trying to will Maurice to live — but it was no use,” said the close family source.

The Bee Gee died at about 1 a.m. on January 12.

“The family is in total shock. Their only consolation is that Robin was there with his twin at the end,” the source added.

As the Bee Gees, Maurice, Robin and Barry have sold more than 110 million albums worldwide, placing them fifth in pop history behind Elvis, The Beatles, Michael Jackson and Paul McCartney. Their disco soundtrack to the hit movie “Saturday Night Fever,” sold more than 40 million albums, making it the best-selling soundtrack of its time.

In all, the group won five Grammy Awards and was elected to the Rock and Roll Hall of Fame.

The brothers have battled booze and drug problems and suffered the premature loss of their youngest brother, pop star Andy Gibb, who died of a heart infection at age 30.