OTTAWA/CALGARY, Oct 26 (Reuters) - Malaysian state-owned oil company Petronas was so confident last Friday that its purchase of Progress Energy Resources Corp would be approved by Canada that company officials had drafted a press release to announce the news.

At midnight Kuala Lumpur time, they were flabbergasted to learn that Ottawa wanted more time to make a decision.

Canada's 11th-hour veto of the $5.2 billion deal was the result of miscalculations and miscommunications, Reuters has learned through interviews with a dozen people briefed on the Oct. 19 events.

The ruling stunned investors, driving down Canadian energy stocks and pressuring the Canadian dollar. It also cast doubt on Prime Minister Stephen Harper's repeated assertions that the country has an open door to foreign investment.

The result was an embarrassment for the supposedly pro-business Conservative government, which needs an estimated $660 billion to develop Canada's energy sector over the next decade.

Ottawa, sources said, wanted to approve the Petronas-Progress deal but was afraid that would tie the government's hands when reviewing the much more controversial $15.1 billion bid by China's CNOOC Ltd for Nexen Inc .

Officials were wary of setting a policy on investment by foreign state-owned enterprises that would make things difficult if Canada later decided to take a tougher line on CNOOC-Nexen.

Ottawa sought more time and thought a delay would be a small matter since Petronas had agreed previously to a two-week extension. But no one explained the situation to the Malaysians, who thought they had a done deal, felt blindsided and feared another agenda might be at play.

Petronas had already raised its bid after Progress received a counterproposal, thought to be from a major Western oil company. So it refused to accept an extension and played hard ball, expecting Canada to cave.

``You had them fully expecting that they would say 'No, we aren't going to take the extension' and that they'd be cleared and that would be the end of it,'' said a source who was briefed on the discussions between senior politicians and bankers advising the companies.

Instead, discussions became heated and at 11:57 p.m. Ottawa time, three minutes before the midnight deadline, Industry Minister Christian Paradis put out a terse release that he was rejecting the deal because it did not offer ``net benefit'' to Canada. He gave no details.

Shares of Progress and Nexen sank, as investors feared a similar fate for the CNOOC proposal. The Canadian government tried to play down those expectations, but the opaque nature of Canada's foreign investment guidelines didn't help.

Officials could not say what problems they found with the Progress deal. Indeed, there were no major issues - the transaction had been set for approval until it got caught up in Canada's sensitive ties with China, sources said.

Harper's office declined to comment on whether CNOOC-Nexen derailed the Petronas-Progress approval, or if there had been any miscommunication between the Canadian government and the companies. Paradis declined to comment on either deal.

Progress blamed a ``communication breakdown'' for the veto, but would not give details. Petronas declined to comment.

COSYING UP TO CHINA

Starting in 2009, and intensifying with a visit to Beijing by Harper in February, Canada has been pushing for closer ties with China, a hungry market for Canadian resources.

But Ottawa somehow expected joint ventures, export markets and money for pipelines, without realizing the friendly approach would translate into bids for entire Canadian companies.

``We expected them to buy our oil, not our oil companies,'' one leading Conservative said.

The issue came to a head in the summer. Just weeks after Petronas launched its bid for Progress in June, CNOOC offered to buy Nexen, Canada's No.6 independent energy firm by market value with assets in the oil sands, the U.S. Gulf of Mexico, the North Sea and off the coast of Nigeria.

China had already invested more than C$10 billion in the Albertan oil sands, the world's third largest proven reserve of crude, by buying small companies or taking minority interests. But Nexen upped the ante.

``I think there (would) be less of an issue if CNOOC ... had bought an operating interest in the assets. What wasn't expected was to buy the whole goddamn head office,'' said Felix Chee, head of the China Investment Corp's Canada office.

Objections grew louder from Conservative legislators, many of whom are suspicious of China and especially dislike the idea of a state-owned enterprise buying Canadian energy assets.

As the pressure mounted, Harper said Ottawa would clarify its guidelines on foreign investment rules, which center on the nebulous concept of a deal being of ``net benefit'' to Canada.

Canada initially saw no reason to reject the Malaysian oil giant: Petronas was already partnering with Progress to develop a shale-gas field in British Columbia and an LNG terminal on the Pacific coast. The projects were in sync with Canada's wish to diversify energy exports away from the United States, and officials with Industry Canada sent the Petronas-Progress file to Paradis with a recommendation to approve.

The decision deadline was Oct 5, but the government asked for a two-week extension to Oct 19. Investment sources said Paradis had indicated he had too much paperwork to deal with, a signal to the companies that there were no new problems.

But it wasn't just paperwork. Canada realized it had to work out guidelines on foreign investments before answering Petronas, so China could not complain about double standards.

``I think there is some element of Petronas not having given all the commitments that the government was looking for, but perhaps the larger question is just bad timing,'' said Robert Johnston, director of the Eurasia Group's global energy and natural resources practice, who is watching the situation.

THE WAITING GAME

By Sunday the rowback was starting, and ministers hinted that the rejection should not be seen as final or as an indication CNOOC would also be blocked. Harper even contradicted Paradis at one stage, saying the minister has not had enough information to determine if the Petronas deal passed Canada's net benefit test.

Finance Minister Jim Flaherty became the government's conciliatory mouthpiece. ``We welcome foreign direct investment, but the applications, the proposals have to be correct,'' Flaherty told CTV.

Officials from Petronas and Progress this week met with industry ministry officials to discuss ways the bid could be revived. They have 30 days to address concerns.

``What I'm hoping is that (a) bridge can be rebuilt here this week and we can actually have some good effective discussions and move this along,'' Progress Chief Executive Michael Culbert told Reuters. ``We've got willing parties on either side and that's always positive for communications.''

It was not clear what extra commitments Canada could want, given that Petronas already made firm promises on corporate governance, jobs and investment - all points highlighted in Canada's foreign investment guidelines.

Harper, hinting that news on the Petronas bid might come at the same time as a decision on CNOOC and the new investment guidelines, promises more details soon.

``We will, as I say, give greater clarity on our policy framework going forward when we take a couple of decisions that are before us at the present time,'' he said on Monday.