(Reuters) - Pennsylvania Governor Tom Wolf said on Friday the state will set up its own healthcare exchange if needed to save insurance subsidies for thousands of residents under the federal government's 2010 Affordable Care Act.

The announcement comes ahead of a ruling expected in June from the U.S. Supreme Court in a lawsuit concerning the eligibility of tax subsidies for people in states where the federal government runs health insurance marketplaces.

"In order to protect 382,000 Pennsylvanians from potentially losing subsidies that help them afford health care coverage, I have written to the federal government outlining a contingency plan to set up a state-based marketplace to ensure no one loses their health coverage," Wolf, a Democrat, said in a statement.

He added that his letter to the U.S. Secretary of Health and Human Services does not mean that Pennsylvania must set up a state-based marketplace.

Up to 7.5 million people in at least 34 states that use the federal exchange could lose their tax subsidies if the court disallows the tax subsidies, according to the consulting firm Avalere Health, dealing a possibly fatal blow to the program.

Most of the 50 states have not created their own exchanges.

(Reporting By Karen Pierog; Editing by Alan Crosby)