JANESVILLE, Wisc. — In 2009, as Rep. Paul D. Ryan was railing against President Obama’s $787 billion stimulus package as a “wasteful spending spree,” he wrote at least four letters to Obama’s secretary of energy asking that millions of dollars from the program be granted to a pair of Wisconsin conservation groups, according to documents obtained by the Globe.

The advocacy appeared to pay off; both groups were awarded the economic recovery funds -- one receiving a $20 million grant to help thousands of local businesses and homes improve their energy efficiency, agency documents show.

Ryan’s letters to the energy secretary praising the energy initiatives as he sought a portion of the funding are in sharp contrast to the House Budget Committee chairman’s image as a Tea Party favorite adamantly opposed to federal spending on such programs.

Ryan’s views are garnering new attention since his selection Saturday as Mitt Romney’s running mate.

The documents show that Ryan’s attempts to take advantage of the stimulus funds even after he voted against them was more expansive than previously reported. Ryan was criticized by some House Democrats in 2010 after the Wall Street Journal reported that he was among several Republicans lawmakers who sought the stimulus money for their constituents by, in his case, writing a letter in 2010 to the Department of Labor.

The additional letters include his praise for the energy program’s aims, and clash with his own budget priorities, which call for curtailing many of the same Department of Energy investments that are designed to spur the growth of green technologies and reduce reliance on fossil fuels..

“I was pleased that the primary objectives of their project will allow residents and businesses in the partner cities to reduce their energy costs, reduce greenhouse gas emissions, and stimulate the local economy by creating new jobs,” Ryan wrote to Energy Secretary Steven Chu on December 18, 2009, on behalf of the Wisconsin Energy Conservation Corporation.

Ryan’s campaign spokesman, Brendan Buck, on Monday declined to comment, pointing the Globe to the statement from Ryan’s Capitol Hill spokesman at the time of the Wall Street Journal article in 2010.

“If Congressman Ryan is asked to help a Wisconsin entity applying for existing federal grant funds, he does not believe flawed policy should get in the way of doing his job and providing a legitimate constituent service to his employers,” the spokesman said. The Romney campaign did not respond immediately to a request for comment.

Other departures from small-government orthodoxy by Ryan include his support of President George W. Bush’s Medicare prescription drug program, the TARP bailout of Wall Street, and the auto bailout.

In addition to the appeals for stimulus funds, Ryan also received congressional approval for $5.4 million in earmarks -- appropriations by Congress members for specific favored projects-- in fiscal 2008, according to Taxpayers for Common Sense, a nonpartisan watchdog group. The requests included $3.28 million for bus service in Wisconsin, $1.38 million for the Ice Age National Scenic Trail, and $735,000 for the Janesville transit system.

Stephen Ellis, vice president of Taxpayers for Common Sense, saidRyan “was not a heavy practitioner of earmarks” compared to his Capitol Hill colleagues. But he participated in the process along with other members of Congress, who traditionally win favor back home by providing funds for projects in their districts.

In 2005, Ryan boasted in a letter to constituents that he had voted for a five-year federal transportation bill that would provide Wisconsin with $711.9 million, a 30 percent increase, in annual funding for highway projects. That bill, which authorized work paid through the national Highway Trust Fund, included the infamous Bridge to Nowhere in Alaska.

Ryan also received authorization for preliminary engineering funds for a commuter-rail system linking Kenosha, Racine, and Milwaukee, and a streetcar expansion project in Kenosha.

Ellis said his group could not find any Ryan-sponsored earmarks for fiscal years 2009 and 2010. Earmark sponsors were not required to identify themselves before fiscal 2008.

John Beckord, president of Forward Janesville, a business advocacy organization, said that Ryan’s support of the auto bailout should be considered in the context of Janesville’s devastating loss when General Motors closed its assembly plant there in 2008. An estimated 5,000 jobs were lost from the plant and supporting businesses.

Ryan’s support for the auto bailout did not stop him from striking a stridently negative tone about government spending when the stimulus act of 2009 was being debated, saying it wouldn’t work to stimulate economic growth.

“This trillion dollar spending bill misses the mark on all counts,” said Ryan in a statement from his office. “This is not a crisis we can spend and borrow our way out of – that is how we got here in the first place.”

But later that year, once the bill was passed and signed into law, Ryan sought to make sure his constituents benefited.

On October 5, 2009, he wrote a letter to Chu on behalf of the nonprofit Energy Center of Wisconsin, which was applying for a grant under the Recovery Act’s Geothermal Technologies Program.

Under the grant program the center received a total of $240,000, according to its president, Frank Greb.

The same day Ryan sent another letter advocating for a grant application, in which the Energy Center partnered with Milwaukee Area Technical College, for training building technicians and operators in energy-saving techniques. For that program, the government provided $740,364, according to federal records.

But the biggest payoff came for the Wisconsin Energy Conservation Corporation. Ryan predicted the $20 million grant would be able to “create or retain approximately 7,600 new jobs over the three-year grant period and the subsequent three years.”

Yet in an interview with MSNBC two years later, Ryan again bashed the stimulus package.

“All this temporary booster shot stimulus didn’t work in the stimulus package, didn’t work when the last administration tried these things, so we don’t want to go with ideas that have proven to fail, we want ideas that have proven to succeed,” he said in an interview on MSNBC in September 2011. “I think tax reform is the key.”

Ryan’s support for the the initiatives he championed for Wisconsin is not reflected in his budget plan passed by the House earlier this year.

That plan, which did not pass the Senate, would cut the Department of Energy’s discretionary budget from roughly $8 billion annually to $1 billion. Over a decade the proposal would cut nearly $100 billion from electric vehicle and other energy efficiency programs.

“It waves a white flag on competing in energy technology,” said Joshua Freed, vice president for clean energy at Third Way, a nonpartisan Washington think tank. “The rest of the world recognizes the enormous and growing energy market. They are funding innovation, which is hard to finance strictly in the private markets ... That is exactly what the Ryan budget would destroy.”

Bryan Bender can be reached at bender@globe.com. Brian MacQuarrie can be reached at macquarrie@globe.com.