Emails revealed during Sen. Mike Duffy鈥檚 trial are shedding light on what was going on in the Prime Minister鈥檚 Office as Stephen Harper鈥檚 inner circle attempted to avert an unfolding Senate expense scandal.

Nigel Wright

The latest emails were introduced in an Ottawa courthouse Thursday, as Duffy鈥檚 defence lawyer Donald Bayne cross-examined Nigel Wright, Harper鈥檚 former chief of staff and a star witness in the criminal trial.

The long chains of damaging emails date between February and May 2013, and include exchanges between Wright, Duffy, other senators, journalists, legal counsel and various key aides in Harper鈥檚 office.

At a campaign stop in Regina on Thursday, Harper insisted he was unaware of the secret plan devised by his own staff to bail out Duffy.

But newly released emails suggest a PMO in crisis.

On May 14, 2013, hours before 麻豆影视 first broke the story that Nigel Wright paid Duffy鈥檚 expense claims, Harper鈥檚 then-communications director Andrew MacDougall alerted his inner circle.

Mike Duffy trial

鈥淗eads up,鈥 he wrote of the 麻豆影视 report.

Through email, MacDougall said he spoke to Wright and told CTV 鈥淚鈥檓 neither confirming nor denying any Nigel involvement.鈥

Mike Duffy trial

Another communications aide, Carl Vallee, asks: 鈥淲ould the PM know the actual answer to the question? Just in case he asks us.鈥

Mike Duffy trial

Wright replies: 鈥淭he PM knows, in broad terms only, that I personally assisted Duffy when I was getting him to agree to repay the expenses.鈥

Mike Duffy trial

But on Thursday, Harper said he only knew one day later, on May 15 of that year.

鈥淢r. Wright has been crystal clear: He did not tell me that, he said that in court,鈥 Harper said. 鈥淗e told me that on May the 15th, when I became aware that in fact, Mr. Duffy had not paid the expenses as I had requested, as Mr. Duffy had claimed he had done.

Mike Duffy trial

鈥淲hen I found out that was not true, I made it immediately public.鈥

Emails show the PMO was getting increasingly worried about Duffy鈥檚 housing expenses. So Wright asked the prime minister鈥檚 legal counsel, Benjamin Perrin, to look at changing the definition of residency rules.

鈥淚 am gravely concerned that Sen. Duffy would be considered a resident of Ontario,鈥 Wright writes.

Perrin then floats the idea 鈥渙f a more flexible alternative 鈥 on main question of what the residency qualification means.鈥

Wright suggests stacking the Senate committee with Conservatives to endorse the changes, saying: 鈥淚f the committee doesn鈥檛 have the right membership, then the Senate by motion should constitute a special committee that will have the right Senators on board. We cannot rely on the Senate Leaders鈥 office to get this right.鈥

Two days later, Wright writes: 鈥淚 think we should lay out the approach in a brief memo to the PM.鈥

Mike Duffy trial

As the Tory plan began to crumble, it appears Duffy was feeling the pressure.

Duffy writes to the prime minister鈥檚 then-principal secretary, Ray Novak: 鈥淩ay, I am cooked. I did nothing wrong.鈥

Mike Duffy trial

Duffy believes the PMO strategy has backfired, and that he鈥檒l take the fall.

鈥淚 swing between team player mode and do anything for pmsh (Prime Minister Stephen Harper) and it is time for me to say phack it,鈥 Duffy writes.

It鈥檚 still unclear if Wright quit or was fired as the PM鈥檚 chief of staff.

Novak, who replaced Wright as chief of staff, was looped in on many of the emails. He is currently in Harper鈥檚 inner circle for his re-election campaign.

NDP MP Charlie Angus alleged Thursday that the emails show a pattern of 鈥渃orruption, collusion鈥 and 鈥渃over-up.鈥

鈥淎nd it seems that everyone around the prime minister was involved,鈥 Angus said. 鈥淲here was the moral compass here?鈥

With a report by CTV鈥檚 Richard Madan