BOSTON — It’s been a dilemma for late-night revelers in Boston for years: Stay at a club or restaurant until closing at 2 a.m., then compete for an expensive cab ride home, or leave before 1 a.m. to catch the last subway or bus?

Gov. Deval Patrick announced Tuesday that it’s a decision that will no longer have to be made.

The Massachusetts Bay Transportation Authority will run all subway trains and the 15 most popular bus routes until 3 a.m. on Saturdays and Sundays starting sometime next spring, Patrick said. The one-year pilot program, if successful, will be extended.

The service will be financed with $20 million in state money as well as corporate sponsorships, starting with $500,000 from The Boston Globe.

The T currently ends service at 1 a.m., much to the chagrin of many college students and others as well as an increasing number of workers in the city’s high-tech industries, who say they tend to tend to work unconventional hours.

“A vibrant economy demands a public transit system that caters to the residents, students and tourists it serves,” Patrick said. “Extending service on weekend evenings will allow the public to enjoy the many attractions and restaurants the region has to offer and give workers a more cost-effective option for getting home late at night.”

The extended service in response to demand, said Richard Davey, head of the state Transportation Department.

“Our customers are clamoring for more service and this is one thing we can do to help meet that demand,” he said. “My hope is that this will be a popular option for enough customers that we can institute it permanently in the future.”