WASHINGTON (Reuters) - The Boeing Starliner spacecraft is now scheduled to undock from the International Space Station and return to Earth on June 22 with its inaugural astronaut crew, NASA said on Friday, giving more time to finalize planning for the complicated process.

NASA astronauts Butch Wilmore and Suni Williams were launched aboard Starliner June 5 and arrived at the ISS the next day, following a 24-hour flight in which the spacecraft encountered four helium leaks and five failures of its 28 maneuvering thrusters.

"The extra time allows the team to finalize departure planning and operations while the spacecraft remains cleared for crew emergency return scenarios within the flight rules," NASA and Boeing said in a statement.

They are targeting a departure no earlier than June 22, leaving open an opportunity for further extensions of time at the ISS. Starliner, while designed for future six-month missions, can stay docked to the ISS for a maximum of 45 days during its current mission.

The return to Earth is expected to last about six hours and target a location in the desert of Utah, New Mexico or other backup locations, depending on local weather conditions.

Starliner's first flight with astronauts is a crucial last test in a much-delayed and over-budget program before NASA can certify the spacecraft for routine astronaut missions and add a second U.S. crew vehicle to its fleet, alongside SpaceX's Crew Dragon.

The spacecraft during its time docked to the ISS has encountered more problems. A fifth leak of helium - used to pressurize Starliner's propulsion system thrusters - popped up, and separately an oxidizer valve has been stuck, NASA has said.

Those in-flight problems follow years of other challenges Boeing has faced with Starliner, including a 2019 uncrewed test failure where dozens of software glitches, design problems and management issues nixed its ability to dock to the ISS. A 2022 repeat uncrewed test succeeded to dock.

If all goes as planned with Starliner's return of two astronauts back to Earth, Boeing still faces other challenges before making the spacecraft operational and bringing it to market for other non-NASA customers.

(Reporting by Chris Sanders, Joey Roulette and Doina Chiacu; editing by Rami Ayyub, Chizu Nomiyama and Timothy Heritage)