MEXICO CITY — In the television ad, President Enrique Peña Nieto strolls along a beautiful beach, his bare feet in the crystalline water as he talks about his government’s environmental achievements. The Mexican leader has starred in several commercials as his government has poured $2 billion of public money into advertising that effectively promotes its interests.

In a campaign that aired last year, for example, Mr. Peña Nieto was seen touring an aerospace factory, sharing barbecue with ranchers and talking with residents of a new housing project. Open almost any newspaper in Mexico, and full-page ads laud all the schools rebuilt after last year’s earthquake.

The heavy government spending on advertising, a longstanding practice at both the federal and state level in Mexico, has been heavily criticized for encouraging flattering coverage of officials and quieting their critics.

Now, facing a court-ordered deadline, Mexico’s Congress is ready to adopt legislation it says will regulate that spending for the first time. But opposition parties and citizen watchdog groups say the bill, backed by Mr. Peña Nieto’s party, is a sham.